Professional Documents
Culture Documents
Graphs are a concise way to represent a network of computer systems using two forms using Linear
Algebra that are:
1. Adjacency Graph: Given a graph G=(V,E) with n vertices and m edges an Adjacency matrix of
order n x n represented as A where Aij
-> Otherwise 0
GRAPH REPRESENTATION
-> 0 otherwise
1 2
3 4
Uses of Adjacency Matrix
Edge Existence Queries: Easily determine whether there is an edge between two vertices uuu and vvv
by looking at the corresponding entry in the adjacency matrix A. If Auv=1, there is an edge between u
and v.
Counting Adjacent Vertices: Count the number of edges incident to a vertex v by summing the elements
in the corresponding row or column of the adjacency matrix A.
Graph Connectivity: Determine whether a graph is connected or not by examining the connectivity of its
vertices through the adjacency matrix. A graph is connected if there is a path between every pair of
vertices.
Graph Construction: Incidence matrices are useful for constructing graphs from edge lists or vertex-
edge pairs. Each row represents a vertex, and each column represents an edge.
Degree of Vertices: The degree of a vertex v in a graph can be computed by counting the number of 1s
in the corresponding row of the incidence matrix B.
Path and Cycle Detection: Incidence matrices can be used to find paths and cycles in directed graphs
by analyzing the relationships between vertices and edges.
Directed Graph Analysis: Incidence matrices are particularly useful for analyzing directed graphs, where
the directionality of edges matters.
NETWORK CONNECTIVITY
Network connectivity refers to the ability of nodes or devices within a network to communicate with each
other.
Types of Connectivity:
1.Physical Connectivity
2.Logical Connectivity
Problem Statement: Given a network represented by its adjacency matrix A, determine whether the
network is connected or not.
def is_connected(adj_matrix):
n = len(adj_matrix)
visited = [False] * n
dfs(adj_matrix, visited, 0) # Start DFS from vertex 0
return all(visited)