API Reference

Index

Docs

GraphUtils.AbstractCustomNEGraphType
abstract type AbstractCustomNEGraph{G,N,E,ID} <: AbstractCustomNGraph{G,N,ID}

An abstract Custom Graph type, with an underlying graph of type G, nodes of type N with ids of type ID, and edges of type E. All concrete subtypes CG<:AbstractCustomNEGraph must implement the required AbstractCustomNGraph interface in addition to the following methods:

  • out_edges(g::CG) : returns an integer-indexed forward adjacency list fadj such that fadj[u::Int][v::Int] contains the custom edge associated with u → v.
  • in_edges(g::CG) : returns an integer-indexed backward adjacency list badj such that badj[v::Int][u::Int] contains the custom edge associated with u → v.

The above methods are implemented by default if g::CG has the following fields:

  • outedges ::Vector{Dict{Int,E}}
  • inedges ::Vector{Dict{Int,E}}
source
GraphUtils.CachedTreeNodeType
CachedTreeNode{ID} <: AbstractTreeNode{ID}

Abstract type representing a node with a cached value. Concrete subtypes have a cached element (accessed via cached_element(n)).

source
GraphUtils.DistMatrixMapType
DistMatrixMap

Maps team size to the effective distance (computed by Djikstra) between leader (top left) vtxs. A DistMatrixMap is constructed by starting with a base environment grid graph, which is represented as a binary occupancy grid. The occupancy grid is then convolved with kernels of various sizes (which represent configurations of robots moving as a team). The output of each convolution represents a new occupancy grid corresponding to the workspace of the robot team. It is assumed that the "lead" robot is always in the top left of the configuration. If a team of robots wishes to query the distance to a particular target configuration, they pass the leader's current vtx, the leader's target vtx, and the team configuration (shape) to the DistMatrixMap, which returns the correct distance.

source
GraphUtils.VtxGridType
VtxGrid

A matrix such that M[i,j] == v, where v is the index of the vertex whose coordinates are (i,j)

source
Base.copyMethod
Base.copy(e::CachedElement)

Shares the e.element, since it doesn't need to be replaced until set_element! is called. Copies e.is_up_to_date to preserve the cache state.

source
GraphUtils.add_child!Method
function add_child!(graph,parent,node,id)

add node child to graph with id id, then add edge parentchild

source
GraphUtils.add_node!Method
add_node!(g::AbstractCustomNGraph{G,N,ID},node::N,id::ID) where {G,N,ID}

Add node to g with associated id.

source
GraphUtils.add_parent!Method
function add_parent!(graph,child,parent,id)

add node parent to graph with id id, then add edge parentchild

source
GraphUtils.backup_descendantsMethod
backup_descendants(g::AbstractCustomNGraph{G,N,ID},template)

Return a dictionary mapping each node's id to the id of it's closest descendant matching template.

source
GraphUtils.capture_connected_nodesMethod
capture_connected_nodes(G,vtxs,f)

Collect the connected set of nodes in G that intersects with vtxs and such that f(v) == true for each v in the set. Args:

  • vtxs::Union{Int,Vector{Int},Set{Int}}
source
GraphUtils.collect_subtreeFunction
collect_subtree(graph,v,dir=:out)

Return a set of all nodes in the subtree of graph starting from v in direction dir.

source
GraphUtils.config_index_to_tupleMethod
config_index_to_tuple(shape::Tuple{Int,Int}, idx::Int)

Convert a config index to a tuple coordinate representation. Assumes the following layout for config indices given shape (m,n): 1 2 ... n ____________________________ 1 | 1 2 ... n 2 | n+1 n+2 ... 2n ... | m | (m-1)n+1 (m-1)n+2 ... m*n

source
GraphUtils.construct_edge_cacheMethod
construct_edge_cache(vtxs,vtx_map)

Returns a cache such that cache[v] = {(0,1),(0,0),...}, the set of all valid directions in which a robot may move from vertex v.

Arguments:

  • vtxs : a list of integer coordinates
  • vtxmap : a matrix such that `vtxmap[i,j] = v, wherevtxs[i,j] = v`.
source
GraphUtils.construct_expanded_zonesMethod
construct_expanded_zones(vtxs,vtx_map,pickup_zones,dropoff_zones;
    shapes=[(1,1),(1,2),(2,1),(2,2)])

A utility for constructing drop-off/pick-up zones where large-footprint objects need to be delivered. Returns a dictionary mapping vertices to a dict of shape=>vtxs for expanded size delivery zones. For each starting vertex, the expanded zone is selected as the appropriately sized region that overlaps with the original vertex, does not overlap with any obstacles, and has minimal overlap with all other vertices in the zone list.

Arguments:

  • vtxs : a list of integer coordinates
  • vtxmap : a matrix such that `vtxmap[i,j] == v, wherevtxs[v] == (i,j)`
  • zones : a list of integer vertex indices identifying the zones to be expanded
source
GraphUtils.construct_factory_env_from_vtx_gridMethod
construct_factory_env_from_vtx_grid(vtx_grid;kwargs...)

Arguments:

  • vtxgrid : a matrix such that `vtxgrid[i,j] > 0` represents free space, otherwise an obstacle.

Keyword Arguments:

  • cell_width = 0.5 : determines the width of each grid cell when the coordinates of the environment are transformed to continuous Cartesian space.
  • transition_time = 2.0 : determines the nominal travel time for a robot to move from one grid cell to an adjacent one.
  • pickup_zones = Int[] : a list of vertices that represent pick-up points
  • dropoff_zones = Int[] : a list of vertices that represent drop-off points
source
GraphUtils.construct_regular_factory_worldMethod
construct_regular_factory_world()

Returns a GridFactoryEnvironment with regularly spaced obstacle regions surrounded by alternating pick-up and drop-off locations.

Keyword Arguments:

  • nobstaclesx = 2 : number of obstacles in x direction
  • nobstaclesy = 2 : number of obstacles in y direction
  • obs_width = [2;2] : obstacle width in both directions
  • obs_offset = [1;1] : width of buffer region around each obstacle
  • env_pad = [1;1] : env pad
  • env_scale = 0.5 : determines the width of each grid cell when the coordinates of the environment are transformed to continuous Cartesian space.
  • transition_time = 2.0 : determines the nominal travel time for a robot to move from one grid cell to an adjacent one.
source
GraphUtils.construct_vtx_gridMethod
construct_vtx_grid

Returns a matrix M such that MV[i,j] == v, where v is the index of the vertex whose coordinates are (i,j)

Arguments:

  • vtxs : a list of integer coordinates
  • dims : the dimensions of the grid
source
GraphUtils.construct_vtx_mapMethod
construct_vtx_map(vtxs,dims)

Returns a matrix M such that MV[i,j] == v, where v is the index of the vertex whose coordinates are (i,j)

Arguments:

  • vtxs : a list of integer coordinates
  • dims : the dimensions of the grid
source
GraphUtils.contract_by_predicateMethod
contract_by_node_type(g,f)

Constructs a new graph of the same type as g, whose nodes are formed by those for which f(n) == true. Edges are contracted so that, e.g. n1 => n2 => n3 => n4 collapses to n1 => n4 if f(n1) && !(f(n2)) && !(f(n3)) && f(n4).

source
GraphUtils.convolve_with_occupancy_kernelMethod
convolve_with_occupancy_kernel(indicator_grid::IndicatorGrid,kernel)

Construct a new indicator grid corresponding to convolution of the original grid with a kernel. The second argument may be a Matrix{Int} or a Tuple{Int,Int} indicating the size for a ones() kernel.

source
GraphUtils.depth_first_searchFunction
depth_first_search(graph,v,goal_function,expand_function,
	neighbor_function=outneighbors)

Returns the first vertex satisfying goalfunction(graph,v). Only expands v if expandfunction(graph,v) == true.

source
GraphUtils.depth_first_searchFunction
depth_first_search(node::AbstractTreeNode,goal_function,expand_function,
	neighbor_function=outneighbors)

Returns the first vertex satisfying goalfunction(graph,v). Only expands v if expandfunction(graph,v) == true.

source
GraphUtils.edge_coverFunction
edge_cover(G,vtxs,mode=:all)

Get all edges coming from vertices vtxs. If mode=:in, just collect incoming edges. If :out, just outgoing. If :all, both.

source
GraphUtils.edge_sourceMethod
edge_source(edge)

Returns the ID of the source node of an edge. Part of the required interface for edges in an AbstractCustomNEGraph.

source
GraphUtils.edge_targetMethod
edge_target(edge)

Returns the ID of the target node of an edge. Part of the required interface for edges in an AbstractCustomNEGraph.

source
GraphUtils.edge_valMethod
edge_val(edge)

Returns the value associated with an edge. Part of the optional interface for edges in an AbstractCustomNEGraph.

source
GraphUtils.find_index_in_sorted_arrayMethod
find_index_in_sorted_array(array, x)

Assumes that array is already sorted. Returns index at which x would need to be inserted in order to maintain ordering of array. Chooses the smallest index in the case of a tie.

Looks like "Base.searchsorted" does the same thing as this.

source
GraphUtils.get_biggest_treeFunction
get_biggest_tree(graph,dir=:in)

Return the root/terminal vertex corresponding to the root of the largest tree in the graph.

source
GraphUtils.get_cached_value!Method
get_cached_value!(n::CachedTreeNode)

Return the up to date cached value of n. This triggers a reach back to parent nodes if necessary.

source
GraphUtils.get_distanceFunction
get_distance(mtx_map::DistMatrixMap,v1::Int,v2::Int,shape::Tuple{Int,Int}=(1,1),config_idx=1)

Returns the length of the minimum distance collision-free path between vertices v1 and v2 for an object of footprint shape.

Arguments:

  • mtx_map : a DistMatrixMap
  • v1 : an integer corresponding to the source vertex in the graph
  • v2 : an integer corresponding to the destination vertex in the graph
  • shape : the footprint of the object that will move between v1 and v2
  • config_idx : an integer that identifies the position of the reference point within the footprint.
source
GraphUtils.get_files_matchingFunction
get_files_matching(base_path,ext,keywords=[])

Get all files in a directory that match the extension ext, and (optionally) which contain any of keywords

source
GraphUtils.get_vtx_mapMethod
get_vtx_map(g::AbstractCustomNGraph{G,N,ID})

return a data structure (e.g, a 'Dict{ID,Int}') mapping node id to node index.

source
GraphUtils.in_edgesMethod
in_edges(g::AbstractCustomNEGraph{G,N,E,ID})

Returns an integer-indexed backward adjacency list badj (e.g., badj::Vector{Dict{Int,E}}) such that badj[v::Int][u::Int] contains the custom edge associated with u → v.

source
GraphUtils.initialize_vtx_grid_from_indicator_gridMethod
initialize_vtx_grid_from_indicator_grid()

Args: * grid: an indicator grid, where grid[i,j] == 0 denotes that cell (i,j) is free, and grid[i,j] != 0 denotes that the cell is impassable.

Returns: * A matrix whose non-zero elements represent the ids of vertices in a graph embedded in the 2D grid.

source
GraphUtils.insert_to_sorted_array!Method
insert_to_sorted_array!(array, x)

Assumes that array is already sorted. Inserts new element x so that array remains sorted. Requires that Base.isless(a::C,b::C) where C==typeof(x) be implemented.

source
GraphUtils.make_edgeMethod
make_edge(g::G,u,v,val) where {G}

Construct an edge u → v of type _edge_type(g) based on val. Default behavior is to throw an error.

source
GraphUtils.nested_default_dict_getMethod
nested_default_dict_get(dict,k,keylist...;default=nothing)

Query into an arbitrarily deep nested dict until finding a non-dict value or returning default when the current key does not point to a dict. Example

dict = Dict()
nested_default_dict_set!(dict,1,2,"val")
nested_default_dict_set!(dict,1,2,3,"other val")
nested_default_dict_get(dict,1,2) == "val"
nested_default_dict_get(dict,1,2,3) == "val"
source
GraphUtils.nested_default_dict_set!Method
nested_default_dict_set!(dict,keylist...,[val])

Sets the value of a nested dictionary, indexed by a list of keys, to val. If the full keylist does not yet exist, create the intermediate dicts along the way. Example:

dict = Dict()
nested_default_dict_set!(dict,1,2,3,"my val")
source
GraphUtils.node_idMethod
node_id(node)

Return the id of a node. Part of the required node interface for nodes in an AbstractCustomNGraph.

source
GraphUtils.node_iteratorMethod
node_iterator(graph,it)

Wraps an iterator over ids or vertices to return the corresponding node at each iteration.

source
GraphUtils.node_valMethod
node_val(node)

Return the value associated with a node. Part of the optional node interface for nodes in an AbstractCustomNGraph.

source
GraphUtils.one_hotMethod
one_hot(::Type{T},n::Int,i::Int) where {T}

Returns a Vector{T} of length n such that v[i] == 1 and v[j] .== 0 for all j != i.

source
GraphUtils.out_edgesMethod
out_edges(g::AbstractCustomNEGraph{G,N,E,ID})

Returns an integer-indexed forward adjacency list fadj (e.g., fadj::Vector{Dict{Int,E}}) such that fadj[u::Int][v::Int] contains the custom edge associated with u → v.

source
GraphUtils.redirect_to_filesMethod
redirect_to_files(dofunc, outfile, errfile)

redirects output of stdout and stderr to outfile and errfile, respectively. Usage:

redirect_to_files(prefix * ".log", prefix * ".err") do
    compute(...)
end
source
GraphUtils.rem_node!Method
rem_node!

removes a node (by id) from g. Note about LightGraphs.rem_vertex!: "internally the removal is performed swapping the vertices v and nv(G), and removing the last vertex nv(G) from the graph"

source
GraphUtils.remap_idxFunction
remap_idx(m::SparseDistanceMatrix,v,config)

Maps an index and configuration from the base grid to the transformed grid represented by m.graph. config represents the position of the query pt relative to the coordinates that correspond to v.

source
GraphUtils.replace_node!Method
replace_node!(g::AbstractCustomNGraph{G,N,ID},node::N,id::ID) where {G,N,ID}

Replace the current node associated with id with the new node node.

source
GraphUtils.tangent_rateMethod
tangent_rate(S::ParametricSpline,t::Real)

Computes the rate (w.r.t. t) at which the tangent vector to a curve is changing.

source
GraphUtils.topological_sortMethod
topological_sort(G)

Returns a topological sort of the vertices of a graph, with the property that v1 < v2 iff there is not forward path through the graph from v2 to v1. G must be non-cyclic. Can handle disjoint graphs.

source
GraphUtils.transform_iterMethod
transform_iter(f, it) = Base.Iterators.accumulate((a,b)->f(b), it)

Transform iterator that applies f to each element of it.

source
GraphUtils.update_element!Function
update_element!(n::CachedTreeNode,element,args...)

Update cached element of n, and propagate relevant information forward and backward via propagate_forward! and propagate_backward!

source
GraphUtils.validate_edge_cacheMethod
validate_edge_cache(G,vtxs,cache)

Verifies that for a graph G embedded in space such that vertex v has coordinates vtxs[v], every edge v₁ → v₂ is stored in the edge cache. In other words, for every edge v₁ → v₂, the unit direction vector obtained by vtxs[v₂] - vtxs[v₁] is a member of cache[v₁].

Arguments:

  • G : a graph on which the functions vertices and outneighbors can be called
  • vtxs : a list of integer coordinates
  • cache : an edge cache such that e.g. cache[v] = {(0,1),(0,0),...}, the set of all valid directions in which a robot may move from vertex v
source
GraphUtils.validate_embedded_treeFunction
validate_embedded_tree(graph,f=v->get_node(graph,v))

Verify that all graph edges are mirrored by the parent-child structure stored in the nodes.

source
GraphUtils.validate_expanded_zonesMethod
validate_expanded_zones(vtx_map,expanded_zones)

Verify that all vertices of each expanded zone do not overlap with obstacle regions, and that each expanded zone contains the original vertex.

source
GraphUtils.validate_treeMethod
validate_tree(n::AbstractTreeNode)

Ensure that the transform tree is in fact a tree–no cycles, and no duplicate ids

source
GraphUtils.@log_infoMacro
@log_info

A helper macro for printing at various verbosity levels. Usage: @log_info(limit::Int,level::Int,msg...) @log_info(limit::Int,solver,msg...) Args:

  • limit::Int - logging threshold
  • level::Int - the verbosity level
  • msg... - message to print if level > limit
source