Network Basics: Graphs, Matrices, Projections, and Connectivity
Complex Systems · 4/8 · Series index · Notation
Network Basics: Representations, Graph Types, Connectivity, and Matrix Calculations
Unless stated otherwise, graphs are finite and have no self-loops or parallel edges. Directed and weighted cases are identified explicitly.
Basic Terminology and Two Graph Representations
Write a graph as , with node set and edge set . An undirected edge represents a symmetric relation; a directed edge represents . A simple graph has no self-loops or parallel edges; "simple" does not mean that its structure is regular. Complex networks often model systems with heterogeneous degrees and intricate connectivity. The word "complex" is not itself a unique graph-theoretic test.
Adjacency Matrices and Adjacency Lists
First specify the node ordering, then define the adjacency matrix. Rows are sources and columns are targets:
For an undirected graph, the first case means that the two nodes are adjacent. An adjacency list records each node's neighbors. For directed graphs it usually lists out-neighbors; in-neighbors can be stored separately when needed. A simple undirected graph satisfies and . Each edge appears twice in the matrix and once in the adjacency list of each endpoint.
Consider a four-node graph with edge set . Ordering the nodes as gives
The adjacency lists are , , , and . Row sums give the degrees; their total is , so .
Walks, Paths, Cycles, and Subgraphs
-
A walk is a sequence of adjacent nodes and may repeat nodes or edges. Its length is the number of traversed edges.
-
A path conventionally has no repeated nodes. If a question uses a broader informal definition, state the convention you adopt. Each consecutive pair must be joined by an edge, and directions must also match in a directed graph.
-
A cycle returns to its starting node without repeating any other node. In a simple undirected graph, a cycle contains at least edges.
-
A subgraph selects some nodes and some of the original edges between them. An induced subgraph selects nodes and retains every original edge between the selected nodes.
Two nodes are connected if there is a path between them. A connected graph has a path between every pair of nodes. A connected component is a maximal connected subgraph: no additional node can be included while preserving connectivity. An isolated node is itself a component. The largest connected component has the greatest number of nodes; "maximal" and "largest" are different concepts.
Multiple Components and Block Matrices
Group nodes from the same component together. Reordering both rows and columns gives
represents only a node permutation. There are no edges between components, so the off-diagonal blocks are zero. This applies to undirected components and to distinct weak components of a directed graph. Different strong components can have one-way edges between them, so ordering nodes by strong components need not make the adjacency matrix block diagonal.
Worked Example: A Six-Node Undirected Graph
Consider the edge set
Here denotes the undirected edge , not the number twelve. If edges – and – cross in a drawing, their crossing does not create an extra node.
1. Adjacency Matrix and Adjacency Lists
Use the node ordering :
2. Node Degrees
Row sums give . Check that . The mean degree is , and the density is .
3. Classifying Paths and Cycles
-
––––: neither, because – is not an edge.
-
––––: a path of length , because every consecutive pair is joined and no node repeats.
-
––––: a cycle of length . All four edges exist, and only the initial/final node repeats.
4. All Connected Three-Node Subgraphs
For three-node induced subgraphs, check the possible node sets. A three-node graph is connected whenever it has at least two edges. There are 14 connected induced subgraphs. The triangles have node sets
The other 11 are two-edge paths, with node sets
If the question allows deleting original edges while retaining the same node set, each triangle additionally produces three connected paths, one for each edge removed. The total is then labeled connected subgraphs. If only distinct shapes are required, ignoring labels, there are just two types: the path and the triangle . State which definition of subgraph is being used.
5. Delete Nodes 3 and 4 Simultaneously
Deleting a node also deletes every incident edge. The remaining nodes are and the remaining edges are , so the components are and . With ordering , the matrix has a connected block in the upper left and a single zero block in the lower right.
Graph Types, Tests, and Real-World Examples
A graph can belong to several classes at once: for example, an even cycle is regular, bipartite, and planar.
Complete Graphs
Every pair of distinct nodes is joined by an edge. The complete graph is denoted ; every node has degree , and . For example, a friendship graph of a small group is complete if every pair of members knows each other directly. Being able to reach all other nodes by paths only means connectedness; it does not mean that every pair is directly joined.
Regular Graphs
A graph in which every node has the same degree is called -regular. The handshaking lemma gives
Therefore must be even, and a simple graph also requires . An unbroken ring communication network, with each node connected to its left and right neighbors, is -regular. For , the edge count is . A square lattice with open boundaries usually has different degrees at the boundary, so it is not automatically regular.
Bipartite Graphs
The nodes can be split into disjoint sets so that every edge crosses between the sets and no edge joins two nodes in the same set. Not every possible cross-set edge needs to exist. Examples include user–movie, student–course, and actor–movie networks. To test bipartiteness, try coloring nodes with two colors so that the endpoints of every edge have different colors. Any odd cycle rules out bipartiteness. In particular, a triangle is not bipartite, while every tree is bipartite.
Trees and Forests
A tree is an undirected graph that is connected and acyclic. An acyclic graph with several components is a forest. A tree satisfies
A forest with components has . Examples of trees include an organizational hierarchy without cross-reporting and a directory hierarchy; a tree with has edges. The edge count alone does not prove that a graph is a tree: a further condition such as connectedness or acyclicity is needed. A triangle plus an isolated node has but is not a tree.
Planar Graphs
A graph is planar if it can be drawn in the plane so that edges meet only at shared endpoints and never cross elsewhere. An idealized road network without overpasses, with intersections treated as nodes, is an example; every tree is planar. Crossings in one drawing do not show that a crossing-free drawing is impossible. Merely seeing a crossing is therefore not a proof of nonplanarity.
Multilayer Networks
A multilayer network consists of layers representing different node or relation types, together with interlayer connections. For example, a power-grid layer and a communication layer can be connected through power-supply and control dependencies. Different layers may have different node sets. Explain what both the within-layer and between-layer edges represent.
Multiplex Networks
A multiplex network is a special multilayer network in which each layer represents the same objects but a different relation. Examples are friendship, coworker, and family layers on the same people, or airline and railway layers on the same cities. The layers provide different representations of the same objects. A multiplex network is not the same as a multigraph, which allows parallel edges between a pair of nodes.
Identifying a Graph Type from Its Meaning
State what the nodes represent, what the edges represent, and why the definition is satisfied. For example: "In a student–course network, the two node types are students and courses; enrollment edges only join students to courses, so the graph is bipartite." The phrase "social network" alone does not establish whether a graph is complete, regular, or bipartite.
Bipartite Matrices and Projections: A Worked Example
A bipartite graph can be represented by a rectangular incidence matrix : rows correspond to objects in one set, columns to objects in the other, and indicates an association. Ordering all nodes in before all nodes in gives the square adjacency matrix
is the rectangular bipartite representation. Distinguish it explicitly from the square adjacency matrix containing all nodes.
Specifying the Bipartite Graph
Let the row nodes be , and the column nodes be . The associations are
Thus, distinguishing the matrix named from the node named ,
The original bipartite graph has nodes and edges. Its full adjacency matrix is obtained by substituting this into the block matrix above.
Projection onto
Two row nodes are joined in the row projection whenever they share a column neighbor. Matrix multiplication gives the number of shared neighbors:
The diagonal entries are the row nodes' degrees in the original bipartite graph; they should not be treated as projection self-loops. Set the diagonal to zero, then replace every positive entry by to obtain the unweighted projection:
In the weighted projection, the edge between and has weight , since they share associations with ; every other existing projection edge has weight .
Projection onto
For the column projection use , again removing the diagonal and binarizing:
For example, nodes both connect to row nodes , so their weighted projection edge has weight ; all other projection edges have weight . A user–movie recommender can use shared movies to express user similarity, or shared users to express movie similarity; a ratings matrix can retain numerical weights. Projection loses information about which particular group created an association and can turn one group into a complete subgraph.
Directed and Weighted Networks, and Directed Components
Direction and weight are independent properties: a graph can be undirected and unweighted, undirected and weighted, directed and unweighted, or directed and weighted.
Directed Adjacency Matrices
We still use for , and generally . A directed graph can nevertheless have every edge paired with its reverse, making its adjacency matrix symmetric. Thus, a directed adjacency matrix need not be asymmetric. Without self-loops,
A node's total degree is , so summing total degrees over the network still gives . If a question adopts the transposed adjacency convention, interchange the row-sum and column-sum rules accordingly.
Weighted Adjacency Matrices
Use to record edge strength, distance, capacity, flow, or another numerical attribute. An absent edge is usually represented by , but if zero is a valid edge weight, store connectivity separately. Undirected weights satisfy . Unweighted degree counts edges; the sum of edge weights is called strength:
For example, if has weight and has weight , then but . When weights represent distance, adding them along a path is meaningful for shortest-path calculations. When weights represent similarity or connection strength, a larger value usually does not mean a longer path; explain how the weights are interpreted.
Strong and Weak Connectivity
A strongly connected component (SCC) is a maximal node set in which every pair is mutually reachable along directed paths. A weakly connected component (WCC) is a maximal connected component after all edge directions are ignored. Every SCC belongs to one WCC, but a WCC need not be strongly connected. A single node without a self-loop can be an SCC because a path of length from a node to itself is allowed.
A Node's In-Component and Out-Component
Using paths of length zero, both sets include itself. They generally overlap and do not form a disjoint partition of the graph. Their intersection is exactly the SCC containing :
Find the out-component by following arrows forward; find the in-component by tracing arrows backward.
Example: Distinguishing the Four Concepts
Consider edges . Ignoring directions connects all five nodes, so there is one WCC. The SCCs are , , and . For node ,
Although node is weakly connected to , it cannot reach and cannot be reached from . Having a common destination, node , does not imply mutual reachability.
Degrees and Two-Step Neighbors: A Worked Example
Consider a six-node directed graph with edges . With node ordering ,
The row sums and column sums respectively give
Both vectors sum to , so . Ignoring directions produces an undirected adjacency matrix, whose degrees are and total degree is . The directed graph is itself strongly connected: forms a cycle through five nodes, and makes node mutually reachable with that cycle.
Why Compute ?
By the definition of matrix multiplication,
Each intermediate node contributes when exists. Thus, counts walks of length exactly from to . More generally, counts walks of length exactly . It does not automatically exclude repeated nodes, and it does not directly count neighbors whose shortest-path distance is .
For this example,
For example, because the two walks and end at the same node . Node therefore has just one distinct two-step destination, ; a row sum of does not mean two distinct second neighbors.
Extracting Neighbors at Exactly Distance Two
If a second neighbor is defined as a node whose shortest-path distance is exactly , then for an unweighted simple graph, or for directed reachability following the given arrows,
Binarize the positive entries, then remove the starting node and nodes already adjacent to it. In this example, is a direct edge, but is also a two-step walk. Hence is not an exact-distance-two neighbor of ; . Matrix powers count walks; exact-distance neighbours require these additional exclusions.
Two Checks for Undirected Graphs
In a simple undirected graph, , since every neighbor supplies a returning walk . For , counts the common neighbors of . For a weighted matrix , is a sum of products of weights along two-step routes, not generally a count of walks or a shortest-path distance.
Hypergraphs, Sparsity, and Computational Representations
Hypergraphs Represent Group Relations
An ordinary edge joins two nodes; a hyperedge can join several nodes at once and is a subset of the node set. A hypergraph may contain hyperedges of size as well as sizes greater than ; their sizes need not all be equal. For example, the complete author list of a paper, the cast of a movie, or the participants in an event can each form one hyperedge.
Treating every hyperedge as an additional node produces a bipartite graph of original nodes and hyperedge nodes. Join an original node to a hyperedge node exactly when it belongs to that hyperedge. The incidence matrix is
The row sum is the number of hyperedges containing a node; the column sum is the size of a hyperedge. Off-diagonal entries of count how many hyperedges a pair of nodes shares. Removing the diagonal and binarizing gives an ordinary graph projection, but loses group structure.
For example, "one event attended by three people" and "three events each attended by a pair" can both project to a triangle, although the hypergraphs differ. The bipartite incidence representation preserves this distinction. Other examples are directors and company boards, keywords and pages on which they occur, stations and train routes, metabolites and reaction participant sets, and users and the items they like.
Density and Mean Degree
Density is the fraction of all allowed edges that are present. A simple undirected graph allows at most edges, so
The final approximation requires large . A directed graph without self-loops allows ordered edges, giving
If a bipartite graph has part sizes , only cross-part edges are allowed. Defining density relative to these allowed pairs gives . Always specify which edges are permitted: the undirected formula cannot be transferred unchanged to directed graphs, multigraphs, or graphs with self-loops.
Sparsity as a Scaling Property
If , the mean degree remains and the density satisfies . A large graph can therefore contain many edges and still be sparse. For example, gives but only . BA has , so : a network can have both hubs and very low density.
The Cost of Adjacency Matrices and Lists
A conventional dense adjacency matrix takes storage, whereas an adjacency list takes . The latter reduces to only when . A matrix can answer an edge-existence query in , but enumerating all neighbors of a node generally requires scanning its row in . An adjacency list enumerates a node's neighbors in . Breadth-first and depth-first traversals using adjacency lists usually take . Sparse matrix formats can also save storage: using a matrix representation does not require allocating a dense array.
Final Self-Check
Core graph-analysis tasks are to convert a graph into an adjacency matrix and adjacency lists and cross-check its degrees and edge count; distinguish paths, cycles, induced subgraphs, and components; calculate edge counts for complete graphs, regular graphs, and trees; construct bipartite projections; obtain in- and out-degrees from row and column sums; identify SCCs, WCCs, in-components, and out-components by following arrows; explain and extract neighbors at exactly distance two; use the correct density formula for each graph type; and state when adjacency lists provide linear storage.
← Scale-free networks · Series index · Network metrics and algorithms →

