This document provides an introduction to graph theory concepts and working with graph data in Python. It begins with basic graph definitions and real-world graph examples. Various graph concepts are then demonstrated visually, such as vertices, edges, paths, cycles, and graph properties. Finally, it discusses working with graph data structures and algorithms in the NetworkX library in Python, including graph generation, analysis, and visualization. The overall goal is to introduce readers to graph theory and spark their interest in further exploration.
Powerful Google developer tools for immediate impact! (2023-24 C)
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
1.
2. This is a novice-track talk, so all concepts and examples are kept simple
1. Basic graph theory concepts and definitions
2. A few real-world scenarios framed as graph data
3. Working with graphs in Python
The overall goal of this talk is to spark your interest in and show you what’s
out there as a jumping off point for you to go deeper
3. Graph: “A structure amounting to a set of objects in which some
pairs of the objects are in some sense ‘related’. The objects
correspond to mathematical abstractions called vertices (also called
nodes or points) and each of the related pairs of vertices is called an
edge (also called an arc or line)” – Richard Trudeau, Introduction to
Graph Theory (1st edition, 1993)
Graph Analytics: “Analysis of data structured as a graph
(sometimes also part of network analysis or link analysis depending
on scope and context)” – Me, talking to a stress ball as I made these
slides
4.
5. • We see two vertices joined by
a single edge
• Vertex 1 is adjacent to vertex 2
• The neighborhood of vertex 1
is all adjacent vertices (vertex
2 in this case)
6.
7. • We see that there is a loop on
vertex a
• Vertices a and b have multiple
edges between them
• Vertex c has a degree of 3
• There exists a path from vertex a
to vertex e
• Vertices f, g, and h form a 3-
cycle
8. • We have no single cut vertex or cut
edge (one that would create more
disjoint vertex/edge sets if
removed)
• We can separate this graph into two
disconnected sets:
1) Vertex Set 1 = {a, b, c, d, e}
2) Vertex Set 2 = {f, g, h}
9. • Imagine symmetric vertex
labels along the top and
left hand sides of the
matrix
• A one in a particular slot
tells us that the two
vertices are adjacent
10. • In this graph two vertices are
joined by a single directed
edge
• There is a dipath from vertex 1
to vertex 2 but not from vertex
2 to vertex 1
11. • Every vertex has ‘played’ every
other vertex
• We can see that there is no clear
winner (every vertex has
indegree and outdegree of 2)
12. • Vertices from Set 1 = {a, b, c, d} are
only adjacent to vertices from Set 2
= {e, f, g, h}
• This can be extended to tripartite
graphs (3 sets) or as many sets as we
like (n-partite graphs)
• Can we pair vertices from each set
together?
13. We can pair every vertex
from one set to a vertex
from the other using only
existing edges
14. • We can assign weights to edges
of a graph
• As we follow a path through the
graph, these weights accumulate
• For example, the path a -
> b -> c has an associated
weight of 0.5 + 0.4 = 0.9
15. • We can assign colors to vertices
• The graph we see here has a
proper coloring (no two vertices
of the same color are adjacent)
• We can also color edges!
16. • Are we focused more on objects or the relationships/interactions
between them?
• Are we looking at transition states?
• Is orientation important?
If you can imagine a graph to represent it, it’s probably worth giving it a
shot, if only for your own learning and exploration!
17. • If the lines represent
connections, what can we say
about the people highlighted
in red?
• What kinds of questions might
a graph be able to answer?
18. • e and d have the highest
degree
• What might the c-d-e cycle
tell us?
• What can we say about cut
vertices?
19. If we have page view
data with timestamps
how might we
represent this as a
graph?
20. • What might loops or multiple edges
between vertices represent?
• What types of data might we want to
use as values on the edges?
• What might comparing indegrees and
outdegrees on different vertices
represent?
21. If we have to regularly pick up a
load at the train station, make
deliveries to every factory and
then return to the garage how can
a graph help us find an optimal
route?
22. • We can assign weights to each edge to
represent distance, travel time, gas cost
for the distance, etc
• The path with the lowest total weight
represents the
shortest/cheapest/fastest/etc
• Note that edge weights are only
displayed for f-e and f-a
23. If the following people want to
attend the following talks (a-h),
what’s the minimum number of
sessions we need to satisfy
everyone?
24. • We can use the talks as
vertices and add edges
between talks that have the
same person interested
• The minimum number of
colors needed for a proper
coloring shows us the
minimum number of
sessions we need to satisfy
everyone
35. • There’s a NetworkX tutorial tomorrow!
• In-browser Graphviz: webgraphviz.com
• Free graph theory textbook: An Introduction to Combinatorics and
Graph Theory, David Guichard
• Open problems in graph theory: openproblemgarden.org
• Graph databases
• Association for Computational Linguistics (ACL) 2010 Workshop on
Graph-based Methods for Natural Language Processing
• Free papers: researchgate.net