- Definition: A graph is a collection of vertices (nodes) connected by edges. Graphs are used to represent relationships between entities.
- Types of Graphs:
- Directed Graph (Digraph): Edges have direction (from one node to another).
- Undirected Graph: Edges do not have direction.
- Weighted Graph: Each edge has a weight or cost.
- Unweighted Graph: No weights are assigned to edges.
- Key Terminologies:
- Vertices (V): The points/nodes in a graph.
- Edges (E): The connections/links between vertices.
- Adjacency List: Represents the graph as a list of vertices, where each vertex’s list contains its neighboring nodes.
- Adjacency Matrix: A 2D matrix representation of a graph where rows and columns represent vertices, and matrix cells indicate edges.
- Degree of a Node: The number of edges connected to a node.