This is well suited to performant lookups of an edge, or listing all edges, but is slow with many other query types.
For example, to find all vertices adjacent to a given vertex, every edge must be examined.
This method has a list, for every vertex, of every element adjacent to that vertex.
It bears resemblance to both edge lists, and adjacency matrices.
Graph theory, like any topic, has many specific terms for aspects of a graph.
First, we should probably take a quick drive past set theory and graph elements, which is important when talking about groups of vertices or edges.
Adjacency lists are the typical choice for “general purpose” use, though edge lists or adjacency matrices have their own strengths, which may match a specific use case.
Abstracting graph access is vital if your graph is going to span more than a single function call.
The body of graph theory allows mathematicians and computer scientists to apply many known principals, algorithms, and theories to their model. It is composed of two kinds of elements, vertices and edges (sometimes called nodes and links in computer science). Let each vertex represent a team, and let each edge represent a game between teams.
Let’s look at using graph theory to quickly solve a problem. I want each of those teams to play exactly 3 games — is this possible? There is a principal, known sometimes as “the handshake lemma”, which states that a graph must have an dd degree).