You are on page 1of 2

Types of Graphs:

Graphs are mathematical structures used to represent relationships between objects.


They are composed of nodes, which represent the objects, and edges, which represent
the connections between the objects.

Un-directed Graphs:

In an un-directed graph, edges do not have a direction, meaning that the connection
between two nodes is mutual. For instance, a social network graph can be represented
as an un-directed graph, where nodes represent people and edges represent
friendships.

Directed Graphs:

In a directed graph, edges have a direction, indicating that the connection between
two nodes is one-way. For example, a road network can be represented as a directed
graph, where nodes represent intersections and edges represent roads.

Weighted Graphs:

In a weighted graph, edges have assigned weights, representing the strength or cost of
the connection between two nodes. For example, a transportation network can be
represented as a weighted graph, where nodes represent cities and edges represent
transportation routes, with weights indicating the travel time or distance between
cities.

Un-weighted Graphs

Un-weighted graphs are graphs in which the edges do not have associated weights.
This means that all edges are considered to have equal cost. Un-weighted graphs are
commonly used to represent relationships between objects, such as social networks or
transportation networks.

Cyclic Graphs

Cyclic graphs are graphs that contain at least one cycle, which is a path that starts and
ends at the same node. Cyclic graphs are often used to represent systems that have
feedback loops, such as electrical circuits or biological networks.

Acyclic Graphs

Acyclic graphs, also known as directed acyclic graphs (DAGs), are graphs that do not contain any
cycles. Acyclic graphs are often used to represent orderings or dependencies between tasks.
Complete Graphs

Complete graphs are graphs in which every node is connected to every other node. Complete
graphs are often used to represent situations in which all possible connections exist, such as a
friendship network in which everyone is friends with everyone else.

Incomplete Graphs

Incomplete graphs are graphs in which not all nodes are connected to every other node.
Incomplete graphs are the most common type of graph, and they are used to represent a wide
variety of relationships.

Breadth-First Search (BFS) and Depth-First Search (DFS)

BFS and DFS are two common graph traversal algorithms used to explore all the nodes in a graph.

Breadth-First Search (BFS)

BFS starts at a starting node and explores all its neighbors before moving on to the
next level of neighbors. It continues expanding outward until it reaches the target
node or has explored all nodes in the graph.

Depth-First Search (DFS)

DFS starts at a starting node and explores as far as possible along a single path until it
reaches a dead end. Then, it backtracks and explores another path until it reaches the
target node or has explored all nodes in the graph.

Applications of BFS and DFS

BFS and DFS have various applications in computer science, including:

Path finding: Finding the shortest path between two nodes in a graph.Shortest
Spanning Tree: Finding the minimum-weight sub-graph that connects all nodes in a
graph.

Network Connectivity: Determining whether there exists a path between two nodes
in a network.

Topological Sorting: Ordering a set of tasks based on their dependencies.

Game Playing: Solving puzzles and navigating game environments.

You might also like