optrees (version 1.0)

repGraph: Visual representation of a graph

Description

The repGraph function uses igraph package to represent a graph.

Usage

repGraph(nodes, arcs, tree = NULL, directed = FALSE, plot.title = NULL, fix.seed = NULL)

Arguments

nodes
vector containing the nodes of the graph, identified by a number that goes from $1$ to the order of the graph.
arcs
matrix with the list of arcs of the graph. Each row represents one arc. The first two columns contain the two endpoints of each arc and the third column contains their weights.
tree
matrix with the list of arcs of a tree, if there is one. Is NULL by default.
directed
logical value indicating whether the graph is directed (TRUE) or not (FALSE).
plot.title
string with main title of the graph. Is NULL by default.
fix.seed
number to set a seed for the representation.

Value

repGraph returns a plot with the given graph.

Examples

Run this code
# Graph
nodes <- c(1:4)
arcs <- matrix(c(1,2,2, 1,3,15, 2,3,1, 2,4,9, 3,4,1),
               byrow = TRUE, ncol = 3)
# Plot graph
repGraph(nodes, arcs)

Run the code above in your browser using DataLab