View on GitHub

reading-notes

Graphs

A graph data structure is a collection of nodes that have data and are connected to other nodes.

What is Vertex in Graph?

It is a node, which is an object with zero or more adjacent vertices.

What is an Edge in Graph?

It is a connection between two nodes or vertex.

What is an Neighbor in Graph?

They are the adjacent nodes of the node.

What is an Degree in Graph?

It is a number of edges connected to that vertex or node.

Directed “Digraph” vs Undirected

Directed graphs is a graph where every edge is directed. Undirected graphs is a graph where each edge is undirected.

Complete vs Connected vs Disconnected

Complete Graphs:

A Complete graph is a simple undirected graph in which every pair of distinct vertices is connected by a unique edge.

Connected Graphs:

It is a graph in which each node has at least one edge.

Disconnected Graphs:

It is a graph in which some node may not have edges.

Acyclic vs Cyclic

Acyclic Graph:

An acyclic graph is a directed graph without cycles.

Cyclic Graph:

A Cyclic graph is a graph that has cycles.

What is Weighted Graph?

It is a graph with graph numbers assigned to its edges.

By using a weight you can make calculation to find the better path, by calculation the total sum of the eges in each path.

Traversals:

We can use either use Breadth First or Depth First in travelling in the gragh.

Depth First:

Breadth First: