Graphs
Explore the foundational concepts of graph theory including vertices, edges, directed and undirected graphs, connectivity, paths, cycles, and graph types such as planar, dependency, and configuration graphs. Understand how these concepts apply to algorithms and problem solving in Python, enhancing your ability to work with graph data structures and perform advanced computations.
We'll cover the following...
Graph
Formally, a simple graph is a pair of sets where is an arbitrary non-empty finite set, whose elements are called vertices or nodes, and is a set of pairs of elements of which we call edges. In an undirected graph, the edges are unordered pairs or just sets of size two. We usually write instead of to denote the undirected edge between and . In a directed graph, the edges are ordered pairs of vertices. We usually write instead of to denote the directed edge from to .
Following standard (but admittedly confusing) practice, we will also use to denote the number of vertices in a graph and to denote the number of edges. Thus, in any undirected graph, we have , and in any directed graph, we have .
The endpoints of an edge or are its vertices and . We distinguish the endpoints of a directed edge by calling the tail and the head.
The definition of a graph as a pair of sets forbids multiple undirected edges with the same endpoints or multiple directed edges with the same head and the same tail. (The same directed graph can contain both a directed edge and its reversal ...