Description Usage Arguments Value Functions Examples
shortestpath provides various graph modification functions that are used internally.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | setInfiniteMinDists(graph, overwrite = TRUE)
setRandomVertexCoordinates(graph, overwrite = TRUE)
setVertexCoordinatesFromLayout(graph, layout = nicely(), overwrite = TRUE)
setEuclideanEdgeWeights(graph, overwrite = TRUE)
setRandomEdgeWeights(graph, dist.fun = function(n) ceiling(runif(n, 0, 10)),
overwrite = TRUE)
setUniformEdgeWeights(graph, overwrite = TRUE)
setEmptyShortestPathPredecessors(graph, overwrite = TRUE)
setRoute(graph, from, to)
setVertexSets(graph, val = NA, overwrite = TRUE)
setAlphabeticalVertexNames(graph, overwrite = TRUE)
permuteGraph(graph)
|
graph |
The original graph object. Will not be modified. |
overwrite |
If |
layout |
An igraph layout function. See |
dist.fun |
A function that accepts the required vector length as an argument and returns a vector of weights of the given length. |
from |
The graph's source vertex for single-source algorithms.
For all-shortest-paths algorithms, |
to |
The graph's target vertex for single-source algorithms.
For all-shortest-paths algorithms, |
val |
the default vertex set value. |
The updated graph object.
setInfiniteMinDists
: Set the minimum distance matrix to infinity.
setRandomVertexCoordinates
: Set random vertex positions for euclidean algorithms.
setVertexCoordinatesFromLayout
: Run the given layout algorithm,
and set the positioning suggested by the algorithm as vertex positions for euclidean algorithms.
setEuclideanEdgeWeights
: Set rounded euclidean edge weights.
setRandomEdgeWeights
: Set random edge weights.
setUniformEdgeWeights
: Set each edge weight to 1.
setEmptyShortestPathPredecessors
: Initialize an empty predecessor matrix.
setRoute
: Set from
and to
and
truncate both min_dists
and shortest_path_predecessors
matrices to the specified source.
setVertexSets
: Initialize each vertex front as val
.
setAlphabeticalVertexNames
: Set vertex names as A-Z. For graphs with more than
26 vertices, vertices will be numbered 1 to N (as characters).
permuteGraph
: Permute both vertex and edge ids.
This is useful so that e.g. Bellman-Ford cannot exploit a graph's artifical structure.
1 2 3 4 5 6 7 8 | library(igraph)
g <- random.graph.game(10, 0.5) %>%
setAlphabeticalVertexNames %>%
setRandomEdgeWeights()
plot(g)
E(g)$weight
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.