Generate adjacency matrices for graphs with visualization. Calculate graph properties and analyze graph structure.
Adjacency Matrix Definition: For a graph with n vertices, the adjacency matrix is an n×n matrix where A[i][j] = 1 (or weight) if there is an edge from vertex i to vertex j, and 0 otherwise.
In graph theory, an adjacency matrix is a square matrix used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not in the graph.
Mathematical Definition:
For a simple graph with vertex set V = {v₁, v₂, ..., vₙ}, the adjacency matrix is an n×n matrix A where:
A[i][j] = 1 if there is an edge from vᵢ to vⱼ, and 0 otherwise.
For weighted graphs, A[i][j] = w if there is an edge from vᵢ to vⱼ with weight w, and 0 otherwise.
| Graph Property | Matrix Property | Example/Explanation |
|---|---|---|
| Undirected Graph | Symmetric matrix | A = Aᵀ (transpose) |
| No self-loops | Zero diagonal | A[i][i] = 0 for all i |
| Degree of vertex i | Sum of row i (or column i for undirected) | deg(vᵢ) = Σⱼ A[i][j] |
| Number of walks length k | Entries of Aᵏ | (Aᵏ)[i][j] = number of walks from i to j of length k |
| Complete Graph Kₙ | All 1's except diagonal | A[i][j] = 1 for i≠j, 0 for i=j |
| Bipartite Graph | Block matrix with zero diagonal blocks | A = [0 B; Bᵀ 0] (after reordering vertices) |
| Connected Graph | Irreducible matrix | No permutation makes it block diagonal |
| Shortest Path (Floyd-Warshall) | Distance matrix D | D[i][j] = shortest distance from i to j |
Floyd-Warshall Algorithm: Computes shortest paths between all pairs of vertices in weighted graphs. Works with both positive and negative edge weights (no negative cycles). Time complexity: O(n³).
Connected Components: For undirected graphs, finds all connected components using DFS/BFS. For directed graphs, finds strongly connected components using Kosaraju's or Tarjan's algorithm.
Graph Isomorphism: Checking if two graphs are isomorphic (same structure) is a challenging problem with no known polynomial-time solution for general graphs.
Advanced Features in This Tool: