學海無涯,思境無維;數乃六藝,理之始也。
或有一得足矣 愚千慮

Graph Theory







%0


a

a



b

b



a--b




c

c



a--c




d

d



a--d




b--c




b--d




c--b




d--b




Simple Directed Graph

{V:VerticesE:EdgesV×V

initial vertex and terminal vertex

degree of a vertex

  • indeg(v) : indegree of v, the number of edges that terminated at v.
  • outdeg(v) : outdegree of v, the number of edges that initiate at v.
  • deg(v) = indeg(v) + outdeg(v)

path : A path between

x and
y
vertices can always be described by its edge list.

  • The initial vertex of
    e1
    is x.
  • The terminal vertex of
    en
    is y.
  • The number of edges in the edge list(n) is path length
  • A edge could only exist once in a path.

circuit : A circuite is a path that terminates at it's initial vertex.

subpath : A subpath is any portion of the path describe by one or more consecutive edges in the edge list.

  • any path is it's own subpath (but improper)
  • all other non-empty subpath are called proper subpath

A path or circuite is simple, if contains no proper subpath that's a circuit.

Multigraph

The graph with a vertex(s) that contains more than one edge to other vertices.

Undirected Graph

The E(edges) are undirected,

e=(a,b)E,(b,a)E

Complete Graph (

Kn)

each pair of distinct vertices are directly connected to one another.

vi,vjV,vivj,(vi,vj)E

Round-robin (Tournament Graph) is a complete graph.







%0


A

A



B

B



A->B





D

D



A->D





C

C



B->C





C->A





C->D





D->B





Single-elimination tournament graph (tree-like):







%0


A

A



B

B



A->B





D

D



A->D





C

C



B->C





  • once vertex(the champion) has no edge terminating at it and at least one edge initiating from it.
  • every other vertex is the terminal vertex of exactly one edge.
  • there is a path from the champion vertex to every other vertex.

Subgraph

let

G=(V,E) be a graph of any kind:

  • directed / undirected
  • multigraph / unidirected

G=(V,E) is a subgraph of
G
,
VVeE

when
eE
and the vertices of
e
are in
V
.

Induced subgraph (Remove vertices and the corresponding edges) : If the only removed edges are thost that include the removed vertices.

Spanning subgraph (Remove the edges only) : no vertices removed from

G, only edges.

Graph Isomorphism

The actual position(embedding) of vertices isn't an essential part of a graph.

Isomorphic Graphs
Two graphs

(V,E) and
(V,E)
are isomorphic if there exists a bijection
f:VV

, such that
(vi,vj)E(f(vi),f(vj))E

Data Structure of Graphs







%0


1

1



2

2



1->2





4

4



1->4





2->4





3

3



2->3





4->1





3->3





  • Adjacency Matrix :
    [aij]
    , where
    aij
    indicates
    (vi,vj)=vivj

    G=(0101001100101000)
  • Edge Dictionary : a list of edges that initiate at that vertex.
    { 1:[2,4],2:[3,4],3:[3],4:[1] }
  • Edge List :
    [(1,2),(1,4),(2,3),(2,4),(3,3),(4,1)]

Connectivity

Let

v and
w
be vertices of a directed graph.

  • is connected :
    v
    is connceted to $w $ if there is a path from
    v
    to
    w
    .
  • strongly connceted : if they are connected in both directions.
  • connected graph : for each pair of distinct vertices (v,w),
    v
    is connected to
    w
    or
    w
    is connected to
    v
    . (complete directed graph?)
  • strongly connected graph : every pair of the connected graph is strongly connected(require both direction). For undirected graph, the edges are all bi-directional, so all connected undirected graph are strongly connected graph.

Maximal Path Theorem

For a graph with

n vertices, the longest path would be
(n1)
.

Adjacency Matrix Method

A graph

G=(V,E)

The adjacency matrix

r that G defines
vi,vjG,virvj(vi,vj)E

rij
indicating if there is an edge connecting
vi
to
vj
.

r=[rij]

virkvj if there exists a path with length
k
between
vi
to
vj
.

Shortest Path - Breadth-First Search (BFS)

Find the path of two connected vertices.

Search for the vertices that is not found yet in each iteration.

{V=v1,v2,,vnvi.found: true if the vertex vi is already found during the searchvi.from: the vertex number that indicates where the vertex vi was found(connected) from.Dk: the depth sets, k is the depth(path length) that store the set of vertices that's was found in that specific depth(length)







%0


1

1



4

4



1->4





5

5



1->5





2

2



4->2





6

6



4->6





5->2





5->6





2->1





3

3



3->1





3->4





3->5





6->1





Search for (2, 3), the path from

v2 to
v3

D0=[2]D1=[1]D2=[4,5]D3=[6]D4=[3]

Distance Matrix

By using the BFS, we can get the distance between any two vertices. Then construct them into a matrix called distance matrix.

dij is the distance(depths) from
vi
to
vj

Examine the matix to get

  • Eccentricity of a Vertex: The maximum distance from a vertex to all other vertices.
    e(v)=max(d(v,w))v,wV,vw
  • Diameter of a graph : the maximum eccentricty distance of vertices as diameter.
    d(G)
  • Radius of a Graph : the minimum eccentricty of vertices in the graph.
    r(G)
  • Center of a Graph : The set of vertices with minimal eccentricity.
    C(G)={vVe(v)=r(G)}

Eulerian

Goal : Traverse all edges once.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Eulerian Path, Circuit and Graph

  • Eulerian Path : a path whose edge list contains each edge of the graph exactly once.
  • Eulerian Circuit : when an Eulerain path is a
    circuit.
  • Eulerian Graph : when the graph contains an Eulerian circuit.

Eulerian PathEulerian CircuitEulerian Graph

Euler's Theorem

An undirected graph has an Eulerian path

it's connected and has 0 or 2 vertices with an odd degree. if no vertex has an odd degree, then the graph is Eulerian

A.K.A.

indeg(v)=outdeg(v) except initial (possible with one more outdegree) and terminal (possible with one more indegree) vertices.

Complete Eulerian Graphs

The complete undirected graphs

K2k+1,kP are Eulerian, if
k>1
, then
K2k
is not Eulerian.

Since all vertices in the complete graph(

Kn) have
n1
edges(degree), therefore when
nEven(n1)Odd
.

Hamilton

Goal : Traverse all vertices once without using the same edge twice.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Hamilton Path, Circuit and Graph

  • Hamilton Path : a path whose vertex list contains each vertex of the graph exactly once except when it's a circuit.
  • Hamilton Circuit : when an Eulerain path is a
    circuit(terminal=initial).
  • Hamilton Graph : when the graph contains an Hamilton circuit.

Hamilton PathHamilton CircuitHamilton Graph

The
n
-cube

n1,Bn :
n
bits binary string
The
n
-cube is the undirected graph with a vertex for each string in
Bn
and an edge connecting each pair of strings that differ in exactly on position. The
n
-cube is normally denoted
Qn
.

Analog-to-digital Convertion(ADC) and the Gray Code







%0


000

000



001

001



000--001




010

010



000--010




100

100



000--100




011

011



001--011




101

101



001--101




010--011




110

110



010--110




100--101




100--110




111

111



011--111




101--111




110--111




Example of Gray Code in

Q3 (aka. The 3-cube).

G1=(01) = The 1-cube.
Gn+1=(0Gn1Gnr)
,
Gnr
: is the reverse of
Gn

G2=(00011110),
G3=(000001011010110111101100)

Graph Optimization

Weighted Graph
A weighted graph,

(V,E,w) is a graph
(V,E)
with a weight function
w:ER
.
eE,w(e)
is the weight of edge
e
.

The salesman problem

Travers all vertices with minimun cost(sum of weights) of the circuit.

The Closet Neighbor Algorithm

Pick the closet(the most light weighted) edge only. It may not be the optimal answer.

The Unit Square Problem

Control the robot arm to weld on all the vertices in the graph with shortest path(circuit).

The Strip Algotirhm

Networks and the Maximum Flow Problem

Network
A network is a simple weighted directed gram that contains two distinguished vertices called the source and the sink with the properties:

  • the indegree of the source and the outdegree of the sink are both zero.
    indeg(source)=outdeg(sink)=0
  • source is connected to sink.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

The Maximum Flow Problem

  • the capacity :
    ei
  • flow :
    f:ER
    • eiE,0f(ei)ei
      : flow can't be larger than the capacity
    • vV,vsourcevsink,f(x,v)=f(v,y)

      for all vertices except source and sink, the sum of flow into v (
      f(x,v)
      ) is equal to it's sum of flow out of v (
      f(v,y)
      ).
    • f(source,x)=f(y,sink)

      Flow out of source equals Flow into sink.
  • The value of a Flow : the two values flow into the sink and flow out of the source were the same, so the common value is called "the value of the flow". denoted by
    V(f)
    .

Ford and Fulkerson Algorithm (FFA)
9.5.24

Flow Augmenting Path

  • w(e)f(e)>0
    : flows forward (unused capacity)
  • w(e)f(e)<0
    : flows in reverse direction

Other Graph Optimization Problems

  • The Minimum Spanning Tree Problem
  • The Minimum Matching Problem
  • The Graph Center Problem
    find the vertex(called a center) of the graph that the distance from the center to every other vertex is as small as possible.

Planarity and Coloring

  • Planarity : a graph be drawn in a plane and no edges intersect(cross).
  • Coloring : color all vertices and no two vertices that are connected by an edge have the same color. (drawing a map so no two bordering countries are colored the same)

The Kuratowski Reduction Theorem states that if a graph is nonplanar then it “contains” either a

K3,3 or a
K5

Euler's Formula

A planar graph devices the plane into one or more regions.

  • Two points on the plane lie in the same region if u can draw a curve connecting the two points that does not pass through an edge.

If

G=(V,E) is a connected planar graph with
r
regions,
v
vertices, and
e
edges,
v+re=2

9.6.10 A Bound on Edges of a Planar Graph

If

G=(V,E) is a connected planar graph with
v
vertices,
v3
and
e
edges,
e3v6

Graph Coloring

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Graph Coloring
Undirected Graph,

G=(V,E) with a "coloring function"
f:VH,(vi,vj)Ef(vi)f(vj)
, and H has the smallest possible cardinality.

The cardinality of

H is called chromatic number of
G
, denoted by
χ(G)
.

The Four-Color Theorem

If

G is a planar graph, then
χ(G)4

The Five-Color Theorem

If

G is a planar graph, then
χ(G)5

tags: math graph