Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Revert "Merge branch 'master' into hotfix-1"
Browse files Browse the repository at this point in the history
This reverts commit dbf785610ef248a26ed5b3a95d7c5d05e447fb89, reversing
changes made to 5f69d5a.

more optimizations

trivial
  • Loading branch information
sbromberger committed Jul 7, 2015
1 parent 4139d2b commit 22d4980
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
22 changes: 11 additions & 11 deletions doc/pathing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ various utility functions. Where appropriate, edge distances may be passed in as
matrix of real number values. The matrix should be indexed by `[src, dst]` (see [Getting Started](gettingstarted.html) for more information).

### Graph Traversal
*Graph traversal* refers to a process that traverses vertices of a graph following certain order (starting from user-input sources). This package implements three traversal schemes:
* `BreadthFirst`,
* `DepthFirst`, and
* `MaximumAdjacency`.
`Graph traversal` refers to a process that traverses vertices of a graph following certain order (starting from user-input sources). This package implements three traversal schemes:
` `BreadthFirst`,
` `DepthFirst`, and
` `MaximumAdjacency`.

`bfs_tree(g, s)`
`dfs_tree(g, s)`
Provides a breadth-first or depth-first traversal of the graph `g` starting with source vertex `s`,
and returns a directed acyclic graph of vertices in the order they were discovered.
`bfs_tree(g)`
`dfs_tree(g)`
Provides a breadth-first or depth-first traversal of the graph `g`, and returns
a directed acyclic graph of vertices in the order they were discovered.


### Connectivity / Bipartiteness
Expand All @@ -25,7 +25,7 @@ of weak connectivity.
`is_weakly_connected(g)`
DiGraphs only: returns true if `g` is strongly (weakly) connected.

`connected_components(g)`
`connected components(g)`
Will return the [connected components](https://en.wikipedia.org/wiki/Connectivity_(graph_theory))
of an undirected graph `g` as a vector of components, each represented by a vector
of vectors of vertices belonging to the component.
Expand Down Expand Up @@ -85,8 +85,8 @@ displayed.

### Shortest-Path Algorithms
#### General properties of shortest path algorithms
* The distance from a vertex to itself is always `0`.
* The distance between two vertices with no connecting edge is always `Inf`.
` The distance from a vertex to itself is always `0`.
` The distance between two vertices with no connecting edge is always `Inf`.


`a_star(g, s, t[, heuristic, distmx])`
Expand Down
10 changes: 6 additions & 4 deletions src/graphvisit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ function examine_edge!(vis::LogGraphVisitor, e::Edge, color::Int)
println(vis.io, "examine edge: $e")
end

function traverse_graph_withlog(g::SimpleGraph, alg::SimpleGraphVisitAlgorithm, sources::Vector{Int}, io::IO)
function traverse_graph_withlog(
g::SimpleGraph,
alg::SimpleGraphVisitAlgorithm,
sources,
io::IO = STDOUT
)
visitor = LogGraphVisitor(io)
traverse_graph(g, alg, sources, visitor)
end

traverse_graph_withlog(g::SimpleGraph, alg::SimpleGraphVisitAlgorithm,
sources::Vector{Int}) = traverse_graph_withlog(g, alg, sources, STDOUT)
14 changes: 14 additions & 0 deletions test/graphvisit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ f = IOBuffer()

g = HouseGraph()
@test traverse_graph_withlog(g, BreadthFirst(), [1;], f) == nothing

@test visited_vertices(g, BreadthFirst(), [1;]) == [1, 2, 3, 4, 5]


function trivialgraphvisit(
g::SimpleGraph,
alg::LightGraphs.SimpleGraphVisitAlgorithm,
sources
)
visitor = TrivialGraphVisitor()
traverse_graph(g, alg, sources, visitor)
end

@test trivialgraphvisit(g, BreadthFirst(), 1) == nothing

0 comments on commit 22d4980

Please sign in to comment.