Reputation: 39
Morning, This was one of my exam questions for data structures and algorithms.
I have to draw a graph on paper based on below array of lists:
The problem I have encountered, is for example:
0->1->4->3
What does it exactly mean? Does it mean 0 has 3 edges to 1 and 4 and 3, or is it just a collection of edges, for example, 0 has edge to 1, 1 has edge to 4, 4 has edge to 3, and so on. I'd appreciate any help with this.
Upvotes: 2
Views: 389
Reputation: 19168
Basically what you are talking about is called "Linked representation" in graph-theory.
0->1->4->3
means that the vertex 0 is connected to 1 and 4 and 3 in a directed way(means arrow is directed from 0 to vertex 1,vertex 4 and vertex 3 respectively).That means that there are three directed edges coming out of vertex 0 to vertices 1,4 and 3 respectively (PLEASE MIND THAT THESE EDGES ARE DIRECTED AS PER YOUR SAYING)!
Similarly,1 simply alone emphasises that there is no directed edge from vertex 1 to any other vertices.
Similarly,2->1
means that there is an edge directed from vertex 2 to vertex 1.
And,3->0->4
means that vertex 3 is directing the edges towards both vertex 0 and vertex 4.
Lastly, 4->2->0
means that there is an edge directed from vertex 4 to both vertex 2 and vertex 0 each.
Upvotes: 1