Hop Subgraphs

Graft provides methods to construct subgraphs using traversals. Consider the following example:

julia> using Graft

julia> g = Graph(20, 60)
Graph(20 vertices, 60 edges, Symbol[] vertex properties, Symbol[] edge properties)

julia> setlabel!(g, map(string, 1 : 20))

julia> # Get a list of vertices, at a distance of 2-3 hops from vertex "1"
       hoplist(g, "1", 2, 3)
3-element Array{String,1}:
 "2"
 "7"
 "18"

julia> # Get a BFS tree starting from the input vertex
       # and terminating at 3 hops distance. Can be used to visualize
       # a BFS traversal
       hoptree(g, "1", 3)
Graph(6 vertices, 5 edges, Symbol[] vertex properties, Symbol[] edge properties)

julia> # Get a subgraph containing all vertices within 3 hops distance,
       # and all edges between them. Can be used to construct the
       # neighborhood of a vertex
       hopgraph(g, "1", 3)
Graph(6 vertices, 10 edges, Symbol[] vertex properties, Symbol[] edge properties)

Detailed documentation:

# Graft.hoplistFunction.

Get a list of vertices at a certain hop distance from a labelled vertex

source

# Graft.hoptreeFunction.

Get the bfs tree starting from the input labelled vertex, and ending at a certain hop distance

source

# Graft.hopgraphFunction.

Get a subgraph containing vertices and edges within a certain hop distance from the input labelled vertex

source