module Graph(Edge, Edge2)
Included Modules
Direct including types
Defined in:
graph.crgraph/bfs.cr
graph/bfs01.cr
graph/bipartite_graph.cr
graph/components.cr
graph/compress.cr
graph/decompose.cr
graph/degree.cr
graph/detect_cycle.cr
graph/dijkstra.cr
graph/kruskal.cr
graph/namori_decompose.cr
graph/topological_sort.cr
graph/tree.cr
graph/tree_walk.cr
Constructors
Class Method Summary
Instance Method Summary
-
#<<(edge : Tuple) : self
Add edge.
-
#<<(edge : Edge2)
Add edge.
- #[](*args, **options)
- #[](*args, **options, &)
- #add_edges(edges : Enumerable) : self
-
#bfs(start : Int) : Array(Int32?)
Returns the array of distance of each node from start or
nil
. -
#bfs!(start : Int) : Array(Int32)
Returns the array of distance of each node from start.
-
#bfs01(start : Int) : Array(Int32?)
Returns the array of distance of each node from start or
nil
. -
#bfs01(start : Int, &) : Array(Int32?)
Returns the array of distance of each node from start or
nil
. -
#bfs01!(start : Int) : Array(Int32)
Returns the array of distance of each node from start.
-
#bfs01!(start : Int32, &) : Array(Int32)
Returns the array of distance of each node from start.
-
#bfs01_st(start : Int, goal : Int) : Int32?
Returns the distance from start to goal if path is present, otherwise returns
nil
. -
#bfs01_st(start : Int, goal : Int, &) : Int32?
Returns the distance from start to goal if path is present, otherwise returns
nil
. -
#bfs01_st!(start : Int, goal : Int, &) : Int32
Returns the distance from start to goal if path is present, otherwise raises
ArgumentError
. -
#bfs01_st!(start : Int, goal : Int) : Int32
Returns the distance from start to goal if path is present, otherwise raises
ArgumentError
. -
#bfs_st(start : Int, goal : Int) : Int32?
Returns the distance from start to goal if path is present, otherwise returns
nil
. -
#bipartite_graph : Array(Bool)?
Returns table of color if the graph is bipartite graph, otherwise returns
nil
-
#components : Tuple(Int32, Array(Int32), Array(Set(Int32)))
Returns
{number of connected components, index, groups}
. -
#compress : self
Returns the graph that deleted isolated vertices.
-
#decompose : Tuple(Array(self), Array(Tuple(Int32, Int32)), Array(Array(Int32)))
Decomposes the graph into each conected components.
- #detect_cycle : Array(Edge)?
-
#diameter
Calculates diameter of the tree and returns
{distance, vertex1, vertex2}
. -
#dijkstra(start : Int)
Returns the array of distance of each node from start or
nil
. -
#dijkstra(start : Int, goal : Int)
Returns the distance of start to goal or
nil
. -
#dijkstra!(start : Int, goal : Int)
Returns the distance of start to goal.
-
#dijkstra!(start : Int)
Returns the array of distance of each node from start.
- #dijkstra_with_path(start : Int, goal : Int)
- #dijkstra_with_prev(start : Int)
-
#each(&) : Nil
Yields each edge of the graph, ans returns
nil
. - #each_child(vertex : Int, parent)
- #each_child(vertex : Int, parent, &) : Nil
- #graph : Array(Array(Edge))
-
#indegree : Array(Int32)
Returns table of indegree.
- #inspect(io : IO) : Nil
-
#kruskal
Calculates cost of minimum spanning tree if the graph is connected, otherwise returns
nil
. -
#namori_decompose : Tuple(self, Array(Int32))
Returns forest and cycle of the undirected graph with equal number of vertices and edges.
-
#outdegree : Array(Int32)
Returns table of outdegree.
- #parent_table(root : Int32) : Array(Int32?)
- #post_order(root : Int) : Array(Int32)
- #pre_order(root : Int) : Array(Int32)
- #reverse : self
- #size(*args, **options, &)
- #size(*args, **options)
- #subtree_size(root : Int32) : Array(Int32)
- #to_s(io : IO) : Nil
- #to_undirected : self
- #topological_sort : Array(Int32)?
-
#tree_distance(root : Int32)
Returns the distance of each node from root.
- #tree_path(start : Int32, goal : Int32, &) : Nil
- #tree_path(start : Int32, goal : Int32) : Array(Int32)
Instance methods inherited from module Enumerable(Edge2)
accumulate(init : U) : Array(U) forall Uaccumulate : Array(T)
accumulate(init : U, &block : U, T -> U) : Array(U) forall U
accumulate(&block : T, T -> T) : Array(T) accumulate, mex : T mex, mex_sorted : T mex_sorted, tally(*, default : Int32) : Hash(T, Int32) tally, unique : self
unique(&) : self unique
Constructor Detail
Class Method Detail
Instance Method Detail
Returns the array of distance of each node from start or nil
.
Returns the array of distance of each node from start.
Returns the array of distance of each node from start or nil
.
All of cost of edge must be 0
or 1
.
Returns the array of distance of each node from start or nil
.
block must return 0
or 1
.
Returns the array of distance of each node from start.
All of cost of edge must be 0
or 1
.
Returns the array of distance of each node from start.
block must return 0
or 1
.
Returns the distance from start to goal if path is present, otherwise returns nil
.
All of cost of edge must be 0
or 1
.
Returns the distance from start to goal if path is present, otherwise returns nil
.
block must return 0
or 1
.
Returns the distance from start to goal if path is present, otherwise raises ArgumentError
.
block must return 0
or 1
.
Returns the distance from start to goal if path is present, otherwise raises ArgumentError
.
All of cost of edge must be 0
or 1
.
Returns the distance from start to goal if path is present, otherwise returns nil
.
Returns table of color if the graph is bipartite graph, otherwise returns nil
Returns {number of connected components, index, groups}
.
Decomposes the graph into each conected components.
Returns the array of distance of each node from start or nil
.
Calculates cost of minimum spanning tree if the graph is connected, otherwise returns nil
.
Returns forest and cycle of the undirected graph with equal number of vertices and edges.