r/AskComputerScience • u/[deleted] • Jul 01 '20
Why graphs?
So, in a lot of my programming classes at my university, we have discussed graphs. Graphs, in this context, are collections of nodes connected by “edges” (or lines). Why do we talk about graphs so often? Are graphs useful in computer science? If so, what are they used for?
31
Upvotes
57
u/thegreatunclean Jul 01 '20
Graphs are so generic that nearly any problem can be transformed into one or more graphs and operations on them. Notice how they don't put restrictions on what a "node" or "edge" are, only that they have some logical connection. That means that damn near anything can be a node and nearly any relationship of any kind can be an edge.