Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

GRAPH THEORY

ASSIGNMENT - 5
Fundamental Circuit

DONE BY :
K. R. VIKRAM - CS21B1020
3RD YEAR CSE – NIT PY
Input and Output

• Input : Adjacency Matrix

• Output : Adjacency Matrix of Fundamental Circuit

CS321 - GRAPH THEORY 2


Idea / Description
• Begin by selecting an edge that is not currently part of the spanning tree and
include it in the spanning tree.
• Mark the vertices connected by the selected edge as visited (let's call them
v1 and v2).
• Start a traversal of graph T from v1 to find a path to v2. You can use either a
Breadth-First Search (BFS) or Depth-First Search (DFS) approach.
• Add the edge chosen in step 1 to the path discovered in step 3. This
combination forms one fundamental circuit.
• Repeat steps 1 through 4 for other edges that are not yet part of the
spanning tree to generate a collection of fundamental circuits for the given
spanning tree.
CS321 - GRAPH THEORY 3
Flowchart

CS321 - GRAPH THEORY 4


Working Example
GIVEN GRAPH
Adjacency Matrix
EDGES A B C D E F
A 0 1 0 0 1 0
B 1 0 1 1 0 0
C 0 1 0 0 1 1
D 0 1 0 0 1 0
E 1 0 1 1 0 0
F 0 0 1 0 0 0

CS321 - GRAPH THEORY 5


STEP 1 : Find Spanning Tree

Adjacency Matrix
EDGES A B C D E F
A 0 -1 0 0 1 0
B -1 0 -1 -1 0 0
C 0 -1 0 0 -1 -1
D 0 -1 0 0 1 0
E 1 0 -1 1 0 0
F 0 0 -1 0 0 0

CS321 - GRAPH THEORY 6


STEP 2 : Select Edge (Say D → E)

Adjacency Matrix
EDGES A B C D E F
A 0 -1 0 0 1 0
B -1 0 -1 -1 0 0
C 0 -1 0 0 -1 -1
D 0 -1 0 0 1 0
E 1 0 -1 1 0 0
F 0 0 -1 0 0 0

CS321 - GRAPH THEORY 7


STEP 3 : Add the edge in the spanning tree

CS321 - GRAPH THEORY 8


Resultant Fundamental Circuit

Adjacency Matrix
EDGES A B C D E F
A 0 0 0 0 0 0
B 0 0 1 1 0 0
C 0 1 0 0 1 0
D 0 1 0 0 1 0
E 0 0 1 1 0 0
F 0 0 0 0 0 0

CS321 - GRAPH THEORY 9


Complexities
The time complexity for the given algorithm will be - O(V2)

The space complexity for the given algorithm will be - O(V2)

Here,
V → the number of Vertices

CS321 - GRAPH THEORY 10


THANK YOU

You might also like