I know that perhaps I posed the old question from the dead, but I found it appropriate to comment.
You can create a chart structure for the incident list, and you can also configure it for digraphs.
Consider a LinkedList<Vertex> object and a LinkedList<Edge> object. This will allow you to iterate over all edges and all vertices, but does not contain information about how everything is connected.
Let's say we add some LinkedList<Connection> objects. In fact, one for each Vertex . A Connection is just where a Edge and a Vertex Meet are. This way, Edge will have two Connection objects (for an undirected graph), and Vertex will have one LinkedList<Connection> object representing the connections to each Edge connected to it. This is essentially a list of cases.
You can change this to represent a digraph if you delete some of these Connection objects. More specifically, you will have to choose where to not have these links. You can remove Connection from the associated LinkedList<Connection> if you do not want to see Edge from Vertex (for the example above, N2 will have an empty LinkedList<Connection> ). Instead, you can make optional links to Edge (In the above example, E1 will have one Connection pointing to N2 and one Connection null, allowing you to bypass from E1 to N2, but not return to N1. Your choice of how to implement this will be entirely yours. One of them is more intuitive - Edges are directed, therefore removal connections on Edges to dictate how they go seems logical. e may seem a little more difficult, but useless to stop you jumping on the edge that never lead to the fact that the first searches for depth and depth.
In the form of a point:
In my implementations, I have a list of incidents. Do you need to complete this task?
Strictly speaking, you can get by saving only outgoing edges. However, backtracking algorithms can benefit from being able to follow the links they made. You can, of course, realize some kind of story around this, so probably this is not so important.
If you do both, you will probably need some way to distinguish between incoming and outgoing. Regardless of whether there are two LinkedList<Connection> objects on top, either using the boolean pointingToVertex primitive boolean pointingToVertex to Connection or whatever. Perhaps your Edge will be directed, and the non-oriented edges will be made of two edges indicating opposite paths. Considerations should be made depending on the needs of your structure.
Jbirch
source share