You are on page 1of 10

GRAPH REPRESENTATION

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

-> 1 if there exist an edge b/w i , j

-> Otherwise 0
GRAPH REPRESENTATION

2. Represent a graph using an n×m incidence matrix B, where Bijis:

-> 1 if vertex i is incident on edge j

-> 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.

Path and Cycle Detection


Uses of Incident Matrix

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

Importance of Network Connectivity: Communication, Resource Sharing , Collaboration


Network Connectivity Analysis

Problem Statement: Given a network represented by its adjacency matrix A, determine whether the
network is connected or not.

Algorithm for Network connectivity Analysis:

1. Adjacency Matrix: Consider the adjacency matrix A of the network.


2. Reachability Analysis:
○ Start with an arbitrary vertex v.
○ Perform a depth-first search (DFS) or breadth-first search (BFS) from v to visit all
reachable vertices.
○ Mark visited vertices.
3. Check Connectivity:
○ If all vertices are visited, the network is connected.
○ If there are unvisited vertices, the network is disconnected.
Application : Ascertaining Network Connectivity
def dfs(adj_matrix, visited, v):
visited[v] = True
for i in range(len(adj_matrix)):
if adj_matrix[v][i] and not visited[i]:
dfs(adj_matrix, visited, i)

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)

# Example adjacency matrix


adj_matrix = [
[0, 1, 1, 0],
[1, 0, 0, 1],
[1, 0, 0, 1],
[0, 1, 1, 0]
]

print("Is the network connected?", is_connected(adj_matrix))


Uses of Network Connectivity Analysis

1.Network Reliability: Determine if the network can maintain connectivity


under various failure scenarios (e.g., node or link failures).

2. Routing Optimization: Ensure that routing algorithms are applied only to


connected components of the network, improving efficiency and reducing
overhead.

3.Network Design: Validate the connectivity of network designs to ensure that


all nodes can communicate with each other.

You might also like