Solving Applied Graph Theory Problems in the JuliaGraphs Ecosystem
James P Fairbanks Oct 24, 2018
Georgia Tech Research Institute
1 Introduction The Julia Programming Language
• 1.0 stable release in Aug 2018 • Multiple dispatch • Dynamic Type system • JIT Compiler • Metaprogramming • Single machine, GPU, and distributed parallelism • Open Source (MIT License)
2 Julia Performance Benchmarks
Figure 1: Benchmark times relative to C (smaller is better, C performance = 1.0) (Source: julialang.org)
3 My path to Julia
• Started in pure math (chalk), • Intro programming class (Java) • Grad school in CSE, Cray XMT (C) C++ was too modern • Numpy/Pandas bandwagon (Python) • Numerical Graph Algorithms (Julia)
4 Outline
• LightGraphs.jl • Spectral Clustering • 2 language problem • Fake News • Future Directions
5 LightGraphs.jl
6 LightGraphs.jl is a central vertex
7 Generic Programing in LightGraphs.jl
Interface for subtypes of AbstractGraph.
• edges • Base.eltype • has edge • has vertex • inneighbors • ne • nv • outneighbors • vertices • is directed
8 Numerical Analysis for Spectral Partitioning Spectral Clustering is Graphs + FP
Figure 2: A graph with four natural clusters. 9 Spectral Graph Matrices
Graphs and Linear Algebra 1, if vi ∼ vj Adjacency Matrix Aij = 0, otherwise
Degrees Dii = di = deg(vi ) all other entries 0.
Combinatorial Laplacian L = D − A
Normalized Laplacian Lˆ = I − D−1/2AD−1/2
Normalized Adjacency Aˆ = D−1/2AD−1/2
10 Spectral Graph Types
11 Spectral Graph Types
11 Spectral Graph Types
NonBacktracking operator
B(s,t),(u,v) = Ast ∗ Auv ∗ δtu ∗ (1 − δsv )
11 Graph Clustering is Finding Block Structure
Adjacency Matrix of Scrambled Block Graph Adjacency Matrix of Block Graph 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 0
500 500
1000 1000
1500 1500 destination destination
2000 2000
2500 2500
source source
Figure 3: A Stochastic Block Model graph showing the recovery of clusters. On left the adjacency matrix with a random labeling. On right the adjacency matrix permuted to reveal block structure.
12 The Spectral Sweep Cut Method
• Solve Lˆx = λ2x to accuracy τ − 1 • Sort D 2 x − 1 • Check all n sweep cuts of D 2 x for best partition
• Recursive bisection applies spectral sweep cuts to each part • Can achieve any number of clusters • First step is the bottleneck
• Large τ seems to work in practice • The goal is to ensure that the final partition recovers the clusters
13 The Spectral Sweep Cut Method
• Solve Lˆx = λ2x to accuracy τ − 1 • Sort D 2 x − 1 • Check all n sweep cuts of D 2 x for best partition
• Recursive bisection applies spectral sweep cuts to each part • Can achieve any number of clusters • First step is the bottleneck
• Large τ seems to work in practice • The goal is to ensure that the final partition recovers the clusters
13 The Spectral Sweep Cut Method
• Solve Lˆx = λ2x to accuracy τ − 1 • Sort D 2 x − 1 • Check all n sweep cuts of D 2 x for best partition
• Recursive bisection applies spectral sweep cuts to each part • Can achieve any number of clusters • First step is the bottleneck
• Large τ seems to work in practice • The goal is to ensure that the final partition recovers the clusters
13 Ring of Cliques
Rb,q: q blocks each of size b. t t Jb e1e1 0 ··· e1e1 t t e1e Jb e1e 0 1 1 t t 0 e1e1 Jb e1e1 0 ...... . . . . e et J e et 0 1 1 b 1 1 t t e1e1 0 e1e1 Jb
t where Jb = 1b1b − Ib.
Figure 5: The adjacency matrix Figure 4: A drawing of Rb,q of Rb,q has block circulant laid out to show structure. structure. 14 Ring of Cliques
Rb,q: q blocks each of size b.
Figure 6: A drawing of Rb,q laid out to show structure. 15 Ring of Cliques Correct Partitions