What's the difference between the data structure Tree and Graph?

后端 未结 10 1808
醉话见心
醉话见心 2021-01-29 17:35

Academically speaking, what\'s the essential difference between the data structure Tree and Graph? And how about the tree based search and Graph based search?

相关标签:
10条回答
  • 2021-01-29 18:15

    one root node in tree and only one parent for one child. However, there is no concept of root node. Another difference is, tree is hierarchical model but graph is network model.

    0 讨论(0)
  • 2021-01-29 18:18

    Instead of explaining I prefer to show it in pictures.

    A tree in real time

    A tree in real time

    A graph in real life use

    A real time graph

    Yes a map can be visualised as a graph data structure.

    Seeing them like this makes life easier. Trees are used at places where we know that each node has only one parent. But graphs can have multiple predecessors(term parent is generally not used for graphs).

    In real world, you can represent almost anything using graphs. I used a map, for example. If you consider each city as a node, it can be reached from multiple points. The points which lead to this node are called predecessors and the points which this node will lead to are called successors.

    electrical circuit diagram, the plan of a house, computer network or a river system are few more examples of graphs. Many real world examples can be considered as graphs.

    Technical diagram could be like this

    Tree :

    enter image description here

    Graph :

    enter image description here

    Make sure to refer to below links. Those will answer almost all your questions on trees and graphs.

    References :

    1. http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-17-trees-and-graphs/#_Toc362296541

    2. http://www.community-of-knowledge.de/beitrag/data-trees-as-a-means-of-presenting-complex-data-analysis/

    3. Wikipedia

    0 讨论(0)
  • 2021-01-29 18:21

    Tree is special form of graph i.e. minimally connected graph and having only one path between any two vertices.

    In graph there can be more than one path i.e. graph can have uni-directional or bi-directional paths (edges) between nodes

    Also you can see more details: http://freefeast.info/difference-between/difference-between-trees-and-graphs-trees-vs-graphs/

    0 讨论(0)
  • 2021-01-29 18:22

    In mathematics, a graph is a representation of a set of objects where some pairs of the objects are connected by links. The interconnected objects are represented by mathematical abstractions called vertices, and the links that connect some pairs of vertices are called edges.[1] Typically, a graph is depicted in diagrammatic form as a set of dots for the vertices, joined by lines or curves for the edges. Graphs are one of the objects of study in discrete mathematics.

    0 讨论(0)
提交回复
热议问题