icp/oer/courses/c-advanced/sections/01-introduction/07-graphs/content.md

26 lines
1.0 KiB
Markdown
Raw Normal View History

2018-05-05 22:18:02 +00:00
The last data-structure we are going to cover is the graph.
It is similar to a tree. In fact a tree is a special case
of a graph, because a graph is also allowed to have circles,
nodes that have a path to them self.
Graphs are useful data-structure to encode relations.
For example a road-network or friendships.
To encode the most basic graphs you need two things.
A list of nodes, sometimes called vertices, and a list of edges.
The nodes represent objects and the edges represent their relation.
For example you could have a graph of a road-network, where every
intersection is a node and every street is an edge.
With the edges and nodes you could encode more information, to use in your
algorithm. So the intersections could have an GPS-position and the street
some kind of cost, which indicates the amount of time you need to get to the
other side.
In this task we provided you with a very simplistic graph,
which encodes the relationship between two people.
Your task is to find out, who likes one, which likes them back.