Ontological Layer: Network Relationships
Graphs
Connections, Traversals, and Optimization
The Freedom of Networks
Trees restrict us to strict hierarchies. Graphs shatter those restrictions, allowing any data point to connect to any other. By defining Nodes (Vertices) and Relationships (Edges), we can model maps, social networks, and internet routing. By assigning Weights to these edges, data structures transcend mere storage and become dynamic arenas for powerful optimization algorithms like Dijkstra's Shortest Path and Kruskal's Minimum Spanning Tree.
The 4 Network Nodes
Ontological Mapping: Representation to Optimization
Graph Representation
- Vertices (V) and Edges (E)
- Directed vs Undirected edges
- Adjacency Matrix (O(V²) space)
- Adjacency List (O(V+E) space)
BFS & DFS Traversal
- Breadth-First: Level-by-level (Queue)
- Depth-First: Branch-by-branch (Stack)
- Visited tracking to prevent infinite loops
- Foundation for finding connectivity
Shortest Path (Dijkstra)
- Weighted edges & path cost
- Edge Relaxation (updating best known distance)
- Priority Queue for vertex selection
- Finds optimal path from a single source
Minimum Spanning Tree
- Connect all vertices with minimum total weight
- Must contain NO cycles (it is a Tree)
- Prim's Algorithm (Vertex/Tree growth)
- Kruskal's Algorithm (Edge selection)
05 — Network Algorithms Laboratory
Graphs represent the pinnacle of structural relationships. By combining the linear access disciplines of Stacks and Queues with the hierarchical logic of Trees, we can traverse networks and mathematically guarantee optimal routes through chaotic, interconnected data.