Skip to content

Latest commit

 

History

History
74 lines (49 loc) · 1.33 KB

chapter4.md

File metadata and controls

74 lines (49 loc) · 1.33 KB

Graphs

Graph

Graph is a data structure used to store relationships between elements.

Components:

  • Vertices (nodes or points)
  • Edges (arc or line)

Properties and types:

  • Weighted or unweighted
  • Directed or undirected
  • Cycled or acyclic
  • Planar or non-planar
  • Biconnected
  • Bipartite

Applications

  • Networks
  • Topology
  • Sociology
  • Lexical analysis

Many functions are implemented in special graph databases.

Implementation

Relationships between nodes can be stored in:

  • Matrixes
  • Adjacency lists

Difference with trees

Actually, tree is an acyclic connected graph. They were “invented” after trees.

Graphs Trees
in 1736 in 1857
by Arthur Cayley by Leonhard Euler

Traversal

  • Breadth-first
  • Depth-first

Breadth first

  • Cheney's algorithm for tracing garbage collection
  • shortest path
  • testing a graph for bipartiteness
  • Maze generation algorithm
  • Analysis of networks and relationships

Depth first

  • topological sorting
  • Maze generation

Minimum spanning trees

Minumum spanning tree is when vertices are connected with minimal possible weight.

Shortest paths

  • Dijkstra
  • All in pairs

Links

  1. wikipedia
  2. Neo4j database