Graphs¶
Motivation¶
“Thus you see, most noble sir, how this type of solution bears little relationship to mathematics and I do not understand why you expect a mathematician to produce it rather than anyone else, for the solution is based on reason alone, and its discovery does not depend on any mathematical principle. Because of this, I do not know why even questions which bear so little relationship to mathematics are solved more quickly by mathematicians than by others. In the meantime most noble sir, you have a assigned this question to the geometry of position but I am ignorant as to what this new discipline involves, and as to which types of problem Leibniz and Wolff expected to see expressed this way.”
— Leonhard Euler, describing the Königsberg bridge problem bridge problem in a letter to Carl Leonhard Gottlieb Ehler (April 3, 1736)
Definition¶
A graph is a set of {vertices, nodes, points} and a collection of {edges, lines, arcs} that each connect a pair of vertices.
Attributes¶
- nodes
- edges
Operations¶
- add_node(node)
- add_edge(node1, node2)
- del_node(node)
- del_edge(node1, node2)
- has_node(node)
- has_edge(node1, node2)
- neigbhors(node)
- is_adjacent(node1, node2)