# Graph – Introductions, Explanations and Applications

A graph is a data structure defined as G(V, E) where V is a set of nodes and E is set of edges.

Each edge is a pair of nodes like edge e1 = {v1, v2}, v1, v2 belongs to V(a set of vertices that form the graph). These vertices v1 and v2, are named as Endpoints.

These set of nodes also termed as Vertices or Points.

### Graph Classification:

#### 1. Directed graph and Undirected Graph

A Directed graph shows traversing direction between two nodes.
An Undirected graph shows traversing could be in any direction between two nodes.

#### 2. Weighted Graph and Unweighted Graph

In a weighted graph, all edges have some associated cost.
In an unweighted graph, there is no associated cost to the edges. It just tells whether the two nodes are connected or not.

#### 3. Cyclic and Acyclic graph

If the graph is containing cycle then cyclic graph, otherwise, Acyclic.
A Cycle is a path that starts and end at the same vertex.

#### 4. Connected and Unconnected graph

A Connected graph has all pairs of vertices connected by at least one path.

Failing the connected graph refers as an Unconnected graph. An unconnected graph is further defined as the maximum number of components where a component is a connected subgraph of the unconnected graph.

### Importance of graph:

For representing any kind of network, graph data structure is used. Such as Telephone network, Transportation networks, Social networks like Facebook, Quora etc.
The newsfeed in Facebook, we can consider us as the root and all our adjacent vertices as our friends and so on.
In fact, Graph theory is a separate subject studied under mathematics. It has a very diverse application such as in Biochemistry, Electrical engineering, Computer science, Operational research and many more.

### Terminologies:

1. Degree of a Node
The degree of a node is the number of edges the node has. In fig(i) degree(v1) = 2, degree(v2) = 3; In fig(ii) degree(v2) = 3.
In a directed graph, there are two terms defined indegree and outdegree.

• Indegree – the number of edges to the node. Look at fig(ii), indegree(v1) = 2, indegree(v2) = 2, indegree(v3) = 0
• Outdegree – the number of edges from the node. outdegree(v1) = 0, outdegree(v2) = 1, outdegree(v3) = 2.

2. Path – It is a sequence of adjacent vertices. Path shows the connectivity of two vertices.

In fig(i) path between v4 and v3 is {v4-v2-v3 and v4-v1-v2-v3}. Similarly in fig(ii), path between v4 and v1 is {v4-v1 and v4-v2-v1}
3. Cycle – It is a path that starts and ends with same vertex.
4. Tree – It’s an acyclic graph.
5. Forest – It’s a disjoint set of trees.
6. Spanning Tree – A spanning tree is defined for a connected graph. It’s a subgraph that contains all the vertices.
7. Complete graph – Such graph has all its vertices are connected to each other.

8. Sparse graph and Dense graph – Graph with relatively few edges are sparse graph and graph with a relatively very high number of edges are dense graph.

### Applications:

Following are the broad applications of graph in computer science,

• Network of communication, e.g. Linkedin, telephone network
• Data organization such as in Database.
• The Flow of computation, like representing the flow of signals in an electronic circuit.

Knowledge is most useful when liberated and shared. Share this to motivate us to keep writing such online tutorials for free and do comment if anything is missing or wrong or you need any kind of help.
Keep Learning… Happy Learning.. 🙂

### Recommended -

Subscribe
Notify of
{"ft_lang_label":"__label__en","ft_lang_prob":0.9303268,"math_prob":0.94215345,"size":3472,"snap":"2022-40-2023-06","text_gpt3_token_len":831,"char_repetition_ratio":0.14388697,"word_repetition_ratio":0.009983361,"special_character_ratio":0.23703916,"punctuation_ratio":0.1303725,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99458873,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-28T22:55:14Z\",\"WARC-Record-ID\":\"<urn:uuid:5cbea0df-f929-4097-937f-ce1dc74dd6e1>\",\"Content-Length\":\"60581\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:dbe91f71-e613-40f8-8a58-fbff0ce6aa53>\",\"WARC-Concurrent-To\":\"<urn:uuid:1e670f86-8248-4e1d-bfc9-ce79c14d13ac>\",\"WARC-IP-Address\":\"172.67.169.236\",\"WARC-Target-URI\":\"https://www.codingeek.com/data-structure/graph-introductions-explanations-and-applications/\",\"WARC-Payload-Digest\":\"sha1:MYPVAEZENJGB6UVT2RN4T5D6BLGA3MFQ\",\"WARC-Block-Digest\":\"sha1:VXWUR2KIOOSISO7BMPAIIQ7SEQSUOHR6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030335286.15_warc_CC-MAIN-20220928212030-20220929002030-00627.warc.gz\"}"}