Re: [jgrapht-users] DefaultEdge vs Void
Brought to you by:
barak_naveh,
perfecthash
From: J K. <j.k...@gm...> - 2018-01-06 23:48:53
|
Yes that would work. In Java, any class comes with a constructor, whether you explicitly define it or not. Of course, you would still have to specify a EdgeFactory which creates new instances of your edges. Aside from that, it wouldn't really provide you with a benefit. The edge source and target are stored on the edge. The default types, DefaultEdge or DefaultWeightedEdge extend IntrustiveEdge. Even if your provide your own custom edge type which does not extend IntrusiveEdge, under the hood a Map<YourEdgeType, IntrusiveEdge> will be used which maps your special YourEdgeType edge to a newly created IntrusiveEdge. So in summary, you won't gain anything. For reference, have a look at AbstractBaseGraph, IntrusiveEdgesSpecifics (and one of its implementations UniformIntrusiveEdgesSpecifics). On Sat, Jan 6, 2018 at 1:51 PM, Victor Porton <po...@na...> wrote: > But what if I write the following? > > class MyVoid { > // empty > } > > Graph<T,MyVoid> > > Will this instantiation "work"? > > I ask because it seems to me to store source and target in each edge is > redundant, because in context of its usage the source and target is known. > I ask therefore, if we can use an empty class like MyVoid to avoid storing > source and destination. > > On Sat, 2018-01-06 at 19:56 +0200, Dimitrios Michail wrote: > > Not really. Void is just a placeholder type which cannot be instantiated. > The type you provide for the edges > must be a class that can be instantiated. > > Read about Java Generics in order to understand its purpose ( > https://docs.oracle.com/javase/tutorial/java/generics/index.html). > > There are plenty of examples of graph instantiations in the JGraphT test > cases. > > --Dimitrios > > > On Sat, Jan 6, 2018 at 4:14 PM, Victor Porton <po...@na...> wrote: > > What is the difference between Graph<T,DefaultEdge> and Graph<T,Void>? > > Does the second work? > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > _______________________________________________ > jgrapht-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/jgrapht-users > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > > |