* Vertices (nodes): These represent the objects.
* Edges: These represent the relationships between the vertices.
There are different types of graphs:
* Directed graph: Edges have a direction, indicating a relationship from one vertex to another.
* Undirected graph: Edges have no direction, indicating a two-way relationship between vertices.
* Weighted graph: Edges have associated weights, representing the strength or cost of the relationship.
* Simple graph: A graph with no loops (edges connecting a vertex to itself) and no multiple edges between the same pair of vertices.
Graphs are widely used in various fields, including:
* Computer science: Representing data structures, algorithms, and networks.
* Mathematics: Modeling relationships between mathematical objects.
* Social sciences: Analyzing social networks and relationships.
* Biology: Understanding protein interactions and gene regulatory networks.
* Engineering: Designing circuits and networks.
Here's a simple example:
Imagine a social network where people are represented as vertices and friendships as edges. If person A is friends with person B, there would be an edge connecting their vertices. This would be an undirected graph, as friendship is a two-way relationship.
Overall, a graph is a powerful tool for representing and analyzing relationships between entities, with applications in a wide range of disciplines.