November 2017
Beginner to intermediate
366 pages
7h 59m
English
Any graph can be represented as a matrix, called the adjacency matrix, where the rows and columns are the vertices of the graph. The presence of a value in a particular cell indicates an edge between the vertices. The cells can be populated with the edge weights too.
The get.adjacency function returns the incident or the adjacency matrix of our graph.
Let's look at a small code snippet to find the adjacency matrix for a graph:
> get.adjacency(simple.graph)5 x 5 sparse Matrix of class "dgCMatrix" alice bob charlie david elialice . . . . 1bob . . 1 . .charlie . 1 . 1 1david . . 1 . .eli 1 . 1 . .>
Function get.adjacency extracts the adjacency matrix from a given graph.
Finally, the following code snippet shows operations ...
Read now
Unlock full access