Working with Graph

Thought Page

Graph is a bit different data structure than other data structures. Graph data structure is like a Tree. Its a set of vertices and edges which connect vertices. Lets first understand what Tree is and how Graph is different from Tree. Tree basically represent hierarchical data. For example an Organization structure or Windows Explorer or any other File Handling GUI. Tree is composed of nodes where every node has some data and set of children. So Tree is special case of Graph where Tree has set of restriction like there will be a root node, every non leaf node will have children. In simple terms, Tree is connected graph with no cycles. So Graph is composed of nodes and edges.

How do we represent a Graph. Generally graph is represented with either adjacency list or adjacency matrix. I will use adjacency matrix here.

graph1

So graph contains vertices and edges.
Graphs…

View original post 285 more words

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s