Graph Flashcards
Graph : Types of edge
Graph : Weight & Unweighted
Graph : Simple Graph
Graph : Multi Graph
Graph : Complete Graph
Graph : Pseudo Graph
Graph : Acyclic Graph
Graph : Basic Properties of Graph
Graph : Walk & Path & Trail
Graph : Connected & Strongly Connected
Graph : Adjency Matrix & Adjency List
In summary, the choice between adjacency matrix and adjacency list depends on the characteristics of the graph and the operations to be performed on it.
If the graph is dense or operations like checking for the existence of edges between vertices are frequent, an adjacency matrix might be more suitable.
If the graph is sparse or memory efficiency is important, an adjacency list is usually preferred.
Undirected Graph : Def Structure (AdjList)
Undirected Graph : newListNode (AdjList)
Undirected Graph : CreateGraph (AdjList)
Undirected Graph : addEdge (AdjList)
1️⃣[src]head
2️⃣[dst]head
{
1.newnode
2.link :
From src to dst
From dst to src
}
Undirected Graph : DeleteEdge (AdjList)
Hints:
1.prev
2.current
3.find dst in array[src]
4.link
5.delete
6. Delete (in array [ dst ]) :
redo 3-5 procedures
Undirected Graph : addVertice (AdjList)
Hint :
1.newV
2.realloc
3.intialize array [newV -1]
4.for : link new vertices to each previous vertices
5. update V in Graph
In undirected graph, add a new vertice means it is connected to each previous vertices.
Undirected Graph : deleteVertice (AdjList)
Hint :
1.current (in array [vertex])
2.next
3.while : delete every node in the array [vertext]
4.delete from dst to src :
for:
1️⃣current
2️⃣while: find related node
3️⃣link
4️⃣free
We can add the codes below to make it more precise.
5.move all the AdjNodes in each head forward
6.resize array
Graph : PrintGraph (AdjList)
Directed Graph : addEdge (AdjList)
Hints :
1.newnode
2.link
对比无向图,少了增加从dst到src的边的步骤
Directed Graph : DeleteEdge (AdjList)
Hints:
1.prev
2.current (array [src].head )
3.while : find the node
4.link
5. free
对比无向图,少了删除从dst到src的边的步骤
Directed Graph : addVetice (AdjList)
Hint :
1.newV
2.realloc
3.intialize array [newV -1]
4.for : link new vertices to vertices mentioned in the input value
5. update V in Graph
Directed Graph : deleteVetice (AdjList)
Hint :
1.current (in array [vertex])
2.next
3.while : delete every node in the array [vertext]
4.delete from dst to src :
for:
{
if:
1️⃣current
2️⃣while: find related node
3️⃣link
4️⃣free
}
5.move all the AdjNodes in each head forward
6.resize array
Graph : addition in deleteVetice (AdjList)
How to implement the following instructions?
1.move all the AdjNodes in each head forward
2.resize array