Edge - the line connecting two nodes together or a node to itself
Graph Theory - Types of graph
If a graph has a number associated with each edge - weightedgraph, or network
Graph Theory
The number of edges connected to a node is the nodes... valency, or order
Graph Theory
A walk is a route through a graph
A path is a finitesequence of edges where no node occurs more than once
A trail is a path where no edge appears more than once
A cycle is a walk in which the starting and endingnode are the same and no node appears more than once
A HamiltonianCycle is a cycle which visits every node
Graph Theory - Types of graph
A connected graph is a graph where you can get from any node to any other node
A subgraph is a graph made entirely out of edges and nodes from another graph
A simple graph has only one or no edges between two nodes and includes no loops
A digraph (directedgraph) includes directions on some or all of the edges
Graph Theory - Euler'shandshakelemma
In an undirected graph, the sum of the valencies on a graph is equal to 2 times the number of nodes. Therefore the total valency is alway even
Graph Theory - Special types of graph
A tree is a connected graph with no cycles
A spanning tree is a subgraph with all the nodes and edges of the graph and is a tree
A bipartitegraph has twosets of nodes, x and y. Edges join x to y but not x/y to itself
A completebipartitegraph has all nodes on one side connected to all nodes on the other side
Isomorphicgraphs are the same as each other but drawn in a different arrangement
Graph Theory - n
a tree with n nodes has n-1 edges
a completebipartitegraph with n nodes on the left and m on the right (K_n,m) has nmedges
a completegraph with n nodes (K_n) has n(n-1)/2 edges (trianglenumbers)
Algorithm to check if a graph is planar:
Planarity algorithm
Planarity algorithm:
Find a Hamiltoniancycle
Make this the edge of a polygon
Choose an edge and redraw all edges that cross it on the outside of the polygon
Repeat until planar if the graph is planar
Create a table of "in" or "out" as you go along
What is an adjacencymatrix?
It tells you how many edges join a pair of vertices
What algorithms find a minimumspanningtree?
Kruskal's
Prim's
Kruskal's algorithm:
consider edges in ascending order of weight
if the edge does not create a cycle, tick it and then add it
if it creates a cycle, reject it
Prim'salgorithm:
Start at the point indicated
add the shortest edge
consider all connected edges:
add the shortest edge (which does not create a cycle)
repeat until all vertices connected
Which algorithms help find shortestpaths?
Dijkstra's
Floyd's
Dijkstra's algorithm:
Starting at the vertex indicated, label this 1
add the distance to any directly connected edges in their workingvalues box
repeat on the vertex with the lowest value in the workingvalues box - label this 2 and so on
repeat until all vertices have been given a number
the finalvalue is the minimumdistance from the starting vertex to that vertex and is the smallest value from the workingvalues
the finalvalue in the target vertex is the distance from the starting to the target vertex
Floyd's algorithm:
uses distance and route tables
create a distance table, writing infinity if not directly connected
copy the table but only add in the row and column for (eg. A)
if it would be quicker to go from one vertex to another via A then replace the value with this new value via A
indicate the change with []. Edit the routetable to indicate the route is via A
repeat for all other edges
Comparing Floyd's and Dijkstra's
Floyd's finds the minimumdistance between any pair of vertices whereas Dijkstra's just finds the minimumdistance between one pair of vertices
Finding the minimum distance and route using a distance and route table completed from Floyd's algorithm
eg. use the table to find the min distance between A and C
check the distance table, the distance listed A to C is the minimum distance
check the routetable, check what the letter in row 1 (A) column 3 (C) is. If it is C then the route is direct, eg. if it was B then the quickest route from A to C goes via B
now A to B and B to C must also be checked if they are direct or not
Eulerian graphs
if the valency of every vertex is even then the graph is traversable from any vertex to any other
if the valency of all but two vertices is even then the graph is only traversable from one odd to another