Introduction to Graphs

Blagovesta Stanoeva
26.11.2014
Software University


 

Table of contents

  • The graph structure
  • Types of graphs and their representation
  • Problems of graph theory, Algorithms 
    (an example)
  • Applications of graph theory

What is a graph


  ?

Flashback

http://computationaltales.blogspot.com/

  • Leonhard Euler - 1735
  • The Seven Bridges of Königsberg
  • Challenge - walk all 7 bridges without crossing a bridge twice
  • Negative resolution - that's when it all began
     

The Graph structure

  • Graph - ordered pair  G = (V,E)
     V - finite set of vertices (nodes)
     E - finite set of edges (links) between nodes
  • Captures pairwise relationship between objects
    ‣ Each edge is a pair (v,w), where v, w V
    Loops, parallel and adjacent edges

    ‣ Adjacent and isolated vertices

Types of Graphs

 

  • Directed - the edges are ordered pairs (v, w) != (w, v)
  • Undirected - the edges are unordered pairs (v, w) == (w, v)
  • Mixed - combination of both
  • Dense - number of edges is close to the maximum number
  • Sparse - only few edges
  • Cyclic - directed graph with at least one cycle
    ‣ cycle - path along the edges from a vertex to itself
  • Weighted 
  • and many more ...

 

Graph Representations

  • Depends on:
    ‣ the graph structure
     the manipulation algorithm
  • Two main ways
    Adjacency matrix - faster access, huge amounts of memory
    Adjacency list - smaller memory requirements, good for
    sparse graphs

    Best way of representation: a combination of both

Graph Algorithms

 

  • Elementary: graph-searching algorithms
    Breadth-first search, Depth-first search
  • Single-Source shortest paths:
     Algorithms of Bellman-Ford and Dijkstra
  • All-Pairs shortest paths: 
    ‣ Floyd-Warshall
  • Minimum spanning trees:
    Algorithms of Kruskal and Prim
  • Maximum flow: 
    ‣ Ford-Fulkerson method

 

Prim's algorithm

..demo

Applications of Graph Theory


  • Routing problems
     Computer games - shortest path between two points
     
    Eulerian Path (Circuit) - postman, visiting each street (edge)
    ‣ Hamiltonian Path (Circuit) - postman, visiting each house (node)
    ‣ 
    Map applications
  • Minimum-spanning tree
    Modeling network topologies
  • Maximum flow 
    Transportation networks - traffic problems
  • and many more ...

 

Questions?

Made with Slides.com