Reading Vertices and Edges in a Graph
A graph names a set of vertices and a set or collection of edges connecting pairs of vertices.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Draw a model from three places
Let A, B, and C denote stations. Connections A–B and B–C say that B links directly to both. A and C lack a direct connection but share a route through B. Neighbor lists encode the direct links compactly.
Keep isolated vertices
Adding station D with no service still adds a vertex. An edge list alone cannot reveal that isolated station unless the vertex set is stored. The comparison with an adjacency matrix shows where that information can live.[1]
Keep isolated vertices in the model
A cable diagram can declare terminals A, B, C and D and draw only connections A–B and B–C. D still represents a terminal with no connection. Inferring vertices solely from edge endpoints loses D and changes component counts. See edge lists and matrices.
V = {A,B,C,D}
E = {{A,B},{B,C}}
Incident edges at D: 0
Connected components: {A,B,C}, {D}
Decide what vertices and edges each represent
Edges could instead represent ability to send messages one way. A diagram without arrowheads would then obscure the graph's semantics. Before applying an algorithm, verify the declared vertex set, edge direction and whether weights or repeated edges exist.