java - Custom Edge with jgrapht -



java - Custom Edge with jgrapht -

i want define custom border

public class connection extends defaultweightededge

but when seek utilize super()is possible? should utilize edgefactory when creating graph?

new simpleweightedgraph<sensor, connection>(edgefactory.class);

would sufficient? or should create new class extends edgefactory well?

you not require subclass defaultweightededge create custom edge, next works also. i'm using version 0.9.0 of jgrapht.

class definition :

public class connection { // class implementation // define constructors , methods need }

graph creation :

simpleweightedgraph<sensor, connection> graph; graph = new simpleweightedgraph<sensor, connection>(connection.class);

adding custom border , setting weight :

sensor v1 = // sensor instance sensor v2 = // sensor instance graph.addvertex(v1); graph.addvertex(v2); connection connection = new connection(/* ... */); graph.addedge(v1, v2, connection); graph.setedgeweight(connection, 10.0);

also consider implement equals , hashcode methods of connection class, jgrapht relies on methods since version 0.8.4, see equalsandhashcode article. article provides illustration defaultweightededge subclassed.

java jgrapht

Comments

Popular posts from this blog

ruby on rails - Devise Logout Error in RoR -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

model view controller - MVC Rails Planning -