add_prism: Add a prism of nodes to the graph

Description

With a graph object of class dgr_graph, add a node prism to the graph.

Usage

1
add_prism(graph, n, type = NULL, label = TRUE, rel = NULL)

Arguments

graph

a graph object of class dgr_graph.

n

the number of nodes describing the shape of the prism. For example, the triangonal prism has n equal to 3 and it is composed of 6 nodes and 9 edges. For any n-gonal prism, the graph will be generated with 2n nodes and 3n edges.

type

an optional string that describes the entity type for the nodes to be added.

label

either a vector object of length n that provides optional labels for the new nodes, or, a boolean value where setting to TRUE ascribes node IDs to the label and FALSE yields a blank label.

rel

an optional string for providing a relationship label to all new edges created in the node prism.

Value

a graph object of class dgr_graph.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Create a new graph and add 2 prisms
graph <-
  create_graph() %>%
  add_prism(3, "prism", "a") %>%
  add_prism(3, "prism", "b")

# Get node information from this graph
node_info(graph)
#>    id  type label deg indeg outdeg loops
#> 1   1 prism     a   3     1      2     0
#> 2   2 prism     a   3     1      2     0
#> 3   3 prism     a   3     1      2     0
#> 4   4 prism     a   3     2      1     0
#> 5   5 prism     a   3     2      1     0
#> 6   6 prism     a   3     2      1     0
#> 7   7 prism     b   3     1      2     0
#> 8   8 prism     b   3     1      2     0
#> 9   9 prism     b   3     1      2     0
#> 10 10 prism     b   3     2      1     0
#> 11 11 prism     b   3     2      1     0
#> 12 12 prism     b   3     2      1     0

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.