Book Image

Apache Spark Graph Processing

Book Image

Apache Spark Graph Processing

Overview of this book

Table of Contents (16 chapters)
Apache Spark Graph Processing
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Computing the degrees of the network nodes


We are now going to explore the three graphs, and introduce an important property of a network node, which is the degree of the node.

The degree of a node represents the number of links it has to other nodes. In a directed graph, we can make a distinction between the incoming degree of a node or an in-degree, which is the number of its incoming links, and its outgoing degree or out-degree, which is the number of nodes that it points to. In the following sections, we will explore the degree distributions of the three example networks.

In-degree and out-degree of the Enron email network

For the Enron email network, we can confirm that there are roughly ten times more links than nodes:

scala> emailGraph.numEdges
res: Long = 367662

scala> emailGraph.numVertices
res: Long = 36692

Indeed, the in-degree and out-degree of the employees are exactly the same in this example as the email graph is bi-directed. This can be confirmed by looking at the average...