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, 71 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)
13-element Array{String,1}:
 "6"
 "10"
 "16"
 "15"
 "19"
 "5"
 "4"
 "18"
 "3"
 "7"
 "13"
 "17"
 "12"

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(17 vertices, 16 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(17 vertices, 56 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