I am using DefaultDirectedGraph to create my directed graph, where each vertex is an object.
DefaultDirectedGraph g = new DefaultDirectedGraph(DefaultEdge.class);
I was wondering if it is possible to characterize the edges? For example, I would like to keep the information of the friendship between students.
Or should I have a map between edges and the objects of friendship?
You can certainly store information on the edges. Here is a usecase I recently used myself:
public class Intersection{
public final long latitude;
public final long longitude;
public Intersection(long latitude, long longitude){ ...}
}
public class Street extends DefaultWeightedEdge{
public final String streetName;
public final int speedLimit;
public final Street(...){...}
}
public class RoadNetwork{
public final Graph<Intersection, Street> network=new DefaultDirectedGraph<>(Street.class);
Intersection i1=new Intersection(..);
Intersection i2=new Intersection(..);
Street s=new Street(..);
//Network with 1 street
network.addVertex(i1);
network.addVertex(i2);
network.addEdge(i1,i2,s);
}
Notes: