Operators
Operators transform graphs to produce new graphs.
Function list
Laplacians.adj — Methoda,d = adj(sddm)Create an adjacency matrix and a diagonal vector from an SDD M-matrix. That is, from a Laplacian with added diagonal weights
Laplacians.diagmat — Methodd = diagmat(a)Returns the diagonal weighted degree matrix(as a sparse matrix) of a graph
Laplacians.disjoin — Methodgraph = disjoin(a,b)Create a disjoint union of graphs a and b, with no edges between them.
Laplacians.edgeVertexMat — MethodU = edgeVertexMat(a)The signed edge-vertex adjacency matrix
Laplacians.floatGraph — Methodgraph = floatGraph(a::SparseMatrixCSC)
Convert the nonzero entries in a graph to Float64.
Laplacians.join_graphs! — Methodgraph = join_graphs!(a::IJV, b::IJV, k::Integer)Create a disjoint union of graphs a and b, and then put k random edges between them, merging b into a.
Laplacians.join_graphs — Methodgraph = joinGraphs(a, b, k::Integer)Create a disjoint union of graphs a and b, and then put k random edges between them
Laplacians.lap — Methodl = lap(a)Create a Laplacian matrix from an adjacency matrix. We might want to do this differently, say by enforcing symmetry
Laplacians.line_graph — MethodH = line_graph(G::SparseMatrixCSC)Let G = (V, E) be a graph. The line graph of G is the graph whose vertices are the edges of G in which two are connected if they share an endpoint in G. That is, (u, v),(w, z) is an edge of the line graph if one of {u, v} is the same as one of {w, z}
Laplacians.mapweight — Methodb = mapweight(a, x->rand())Create a new graph that is the same as the original, but with f applied to each nonzero entry of a. For example, to make the weight of every edge uniform in [0,1], we could write.
Laplacians.plot_graph — Methodplot_graph(gr,x,y,z;color=[0,0,1],dots=true,setaxis=true,number=false)Plots graph gr with coordinates (x,y,z)
Laplacians.plot_graph — Methodplot_graph(gr,x,y;color=[0,0,1],dots=true,setaxis=true,number=false)Plots graph gr with coordinates (x,y)
Laplacians.power — Methodap = power(a::SparseMatrixCSC, k::Int)Returns the kth power of a.
Laplacians.product_graph — Methodaprod = productGraph(a0, a1)The Cartesian product of two graphs. When applied to two paths, it gives a grid.
Laplacians.shortIntGraph — Methodgraph = shortIntGraph(a::SparseMatrixCSC)Convert the indices in a graph to 32-bit ints. This takes less storage, but does not speed up much.
Laplacians.spectral_coords — Methodx, y = spectral_coords(a)Computes the spectral coordinates of a graph. If more than 2 coords are desired, you can use
x, y, z = spectral_coords(a; k = 3)Laplacians.spectral_drawing — Methodspectral_drawing(a)Computes spectral coordinates, and then uses plot_graph to draw
Laplacians.subsampleEdges — Methodgraph = subsampleEdges(a::SparseMatrixCSC, p::Float64)Create a new graph from the old, but keeping edge edge with probability p
Laplacians.thicken — Methoda_new = thicken(A,k)Create a new graph with at least k times as many edges as A By connecting nodes with common neighbors at random. When this stops working (not enough new edges), repeat on the most recently produced graph. If k is too big, it is decreased so the average degree will not be pushed much above n/2.
When called without k, it just runs thicken_once.
For example:
a = grid2(5)
a2 = thicken(a,3)
(x,y) = grid2coords(5,5);
plotGraph(a2,x,y)Laplacians.thicken_once — Methoda_new = thicken_once(a)Creates one edge for every vertex in a of degree > 1 by connecting two of its random neighbors. To use this to thicken a, return unweight(a + a_new).
a = grid2(5)
a2 = unweight(a + thicken_once(a))
(x,y) = grid2coords(5,5);
plotGraph(a2,x,y)Laplacians.two_lift — Methodgraph = two_lift(a, flip::AbstractArray{Bool,1})
graph = two_lift(a)
graph = two_lift(a, k::Integer)Creats a 2-lift of a. flip is a boolean indicating which edges cross. In the third version, k is the number of edges that cross.
Laplacians.uniformWeight! — MethoduniformWeight!(a)Set the weight of every edge to random uniform [0,1]
Laplacians.unweight! — Methodunweight!(a)Change the weight of every edge in a to 1
Laplacians.unweight — Methodwt1 = unweight(a)Create a new graph in that is the same as the original, but with all edge weights 1
Laplacians.wtedEdgeVertexMat — MethodU = wtedEdgeVertexMat(a)The signed and weighted edge-vertex adjacency matrix, so U'*U = L