Re: [jgrapht-users] How to color or label vertices using jgrapht libraries?
Brought to you by:
barak_naveh,
perfecthash
From: Joris K. <de...@gm...> - 2015-08-07 15:16:55
|
The graph libraries are generic and very well designed, so you can create your own objects as vertices or edges. Simple (untested) example: public class Example{ public static void main(String[] args){ SimpleGraph<ColorableVertex, DefaultEdge> graph=new SimpleGraph<>(); graph.addVertex(new ColorableVertex(0)); for(ColorableVertex v : graph.vertexSet(){ v.setColor(Color.PINK); } } public class ColorableVertex{ Color color; int id; public ColorableVertex(int id){ ... } public setColor(Color color){this.color=color;} } br, Joris Kinable On Thu, Aug 6, 2015 at 7:49 PM, Steven Barkin <ste...@sa...> wrote: > I am interested in writing a graph coloring algorithm using various types > of directed and undirected graph classes provided by jgrapht. None of them > seem to have an easy ability to do this within the graph class itself (e.g. > DirectedSimpleGraph). > > My goal is to be able to traverse the graph object, and add/change various > labels or colors to the vertices, without the need to store the vertex > information outside the object itself - i.e. I would like to use or create > methods such as "DirectedSimpleGraph.setColorToVertex(v, c), where v is a > vertex. and c is the color which perhaps would be defined as an integer. > Any leads or best practices advice would be greatly appreciated. > > This communication is confidential and subject to and governed by the > confidentiality and use restrictions contained in Saama’s Electronic > Communications Disclaimer. <http://www.saama.com/disclaimer> > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > > |