2015年12月15日星期二

Data Structure --- 5. Graph

Graph is used widely for complex modeling.
  • Undirected vs Directed
  • Cylic vs Acylic 
Without cycle and isolated multiple trees(forest), Graph becomes tree.

Graph can be represented as matrix or adjancecy list. The latter is more programming friendly. The adjancecy list can be represented in several ways
  • List<List<T_vertex_data>>
  • Map<vertex_data, List<T_vertex>>
  • List<Node>, where Node class has List<T_vertex_data>
, where Map is complete graph, not need to build

Graph has two basic algorithms
  • DFS
  • BFS
, which can be used for traversal, Find Connectivity/Path.

Undirected Graph is basic.
NoCycle+IsTree+Not forest ?
DAG is particular interesting And DAG's Topological sort is powerful to solve scheduler dependencies problem

没有评论:

发表评论