repGraph: Visual representation of a graph

Description Usage Arguments Value Examples

Description

The repGraph function uses igraph package to represent a graph.

Usage

1
2
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

1
2
3
4
5
6
# 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)

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

optrees documentation built on May 2, 2019, 8:15 a.m.