DS Menu


Introduction to Graph




Definition of Graph

A graph, in the context of mathematics and computer science, is a data structure used to represent relationships between entities. It consists of two sets:

  • Vertices (V): Represent the entities themselves, also called nodes or points.
  • Edges (E): Represent the relationships between the entities, also called links or lines.
Definition
A graph is denoted as G = (V, E), where:
    -V is a set of vertices.
    -E is a set of edges.

These edges can be directed or undirected:

  • Directed edges: Have an arrow indicating direction, showing how one vertex connects to another (e.g., A → B).
  • Undirected edges: Have no direction, representing a bi-directional connection between two vertices (e.g., A - B).

Graph Terminology

  1. Graph: A collection of nodes (or vertices) and edges that connect pairs of nodes.
  2. Vertex (Node): The fundamental unit by which graphs are formed. A vertex represents a point in the graph.
  3. Edge: A line connecting two vertices in a graph. It can be directed (having a direction) or undirected (no direction).
  4. Directed Graph (Digraph): A graph in which the edges have a direction, indicating a one-way relationship between vertices.
  5. Undirected Graph: A graph in which the edges do not have a direction, indicating a two-way relationship.
  6. Weighted Graph: A graph in which edges have weights assigned to them, typically representing costs, lengths, or capacities.
  7. Unweighted Graph: A graph in which edges do not have weights.
  8. Adjacent (Neighbors): Two vertices are adjacent if there is an edge connecting them.
  9. Degree: The degree of a vertex is the number of edges connected to it. For directed graphs, there are in-degree (edges coming into the vertex) and out-degree (edges going out from the vertex).
  10. Path: A sequence of edges that allows you to go from one vertex to another.
  11. Cycle: A path that starts and ends at the same vertex without traversing any edge more than once.
  12. Loop: An edge that connects a vertex to itself.
  13. Subgraph: A graph formed from a subset of the vertices and edges of another graph.
  14. Connected Graph: An undirected graph is connected if there is a path between every pair of vertices.
  15. Disconnected Graph: A graph is disconnected if it is not connected, i.e., if there are at least two vertices with no path between them.
  16. Complete Graph: A graph in which there is an edge between every pair of vertices.
  17. Bipartite Graph: A graph whose vertices can be divided into two disjoint sets such that every edge connects a vertex in one set to a vertex in the other set.
  18. Tree: A connected, undirected graph with no cycles.
  19. Acyclic Graph: A graph with no cycles. In the context of directed graphs, it is often called a Directed Acyclic Graph (DAG).
  20. Graph Isomorphism: Two graphs are isomorphic if there is a one-to-one correspondence between their vertex sets that preserves edge connectivity.

Next Topic :Graph Representation