Apache Spark Graph Processing

Book description

Build, process and analyze large-scale graph data effectively with Spark

About This Book

  • Find solutions for every stage of data processing from loading and transforming graph data to
  • Improve the scalability of your graphs with a variety of real-world applications with complete Scala code.
  • A concise guide to processing large-scale networks with Apache Spark.

Who This Book Is For

This book is for data scientists and big data developers who want to learn the processing and analyzing graph datasets at scale. Basic programming experience with Scala is assumed. Basic knowledge of Spark is assumed.

What You Will Learn

  • Write, build and deploy Spark applications with the Scala Build Tool.
  • Build and analyze large-scale network datasets
  • Analyze and transform graphs using RDD and graph-specific operations
  • Implement new custom graph operations tailored to specific needs.
  • Develop iterative and efficient graph algorithms using message aggregation and Pregel abstraction
  • Extract subgraphs and use it to discover common clusters
  • Analyze graph data and solve various data science problems using real-world datasets.

In Detail

Apache Spark is the next standard of open-source cluster-computing engine for processing big data. Many practical computing problems concern large graphs, like the Web graph and various social networks. The scale of these graphs - in some cases billions of vertices, trillions of edges - poses challenges to their efficient processing. Apache Spark GraphX API combines the advantages of both data-parallel and graph-parallel systems by efficiently expressing graph computation within the Spark data-parallel framework.

This book will teach the user to do graphical programming in Apache Spark, apart from an explanation of the entire process of graphical data analysis. You will journey through the creation of graphs, its uses, its exploration and analysis and finally will also cover the conversion of graph elements into graph structures.

This book begins with an introduction of the Spark system, its libraries and the Scala Build Tool. Using a hands-on approach, this book will quickly teach you how to install and leverage Spark interactively on the command line and in a standalone Scala program. Then, it presents all the methods for building Spark graphs using illustrative network datasets. Next, it will walk you through the process of exploring, visualizing and analyzing different network characteristics. This book will also teach you how to transform raw datasets into a usable form. In addition, you will learn powerful operations that can be used to transform graph elements and graph structures. Furthermore, this book also teaches how to create custom graph operations that are tailored for specific needs with efficiency in mind. The later chapters of this book cover more advanced topics such as clustering graphs, implementing graph-parallel iterative algorithms and learning methods from graph data.

Style and approach

A step-by-step guide that will walk you through the key ideas and techniques for processing big graph data at scale, with practical examples that will ensure an overall understanding of the concepts of Spark.

Table of contents

  1. Apache Spark Graph Processing
    1. Table of Contents
    2. Apache Spark Graph Processing
    3. Credits
    4. Foreword
    5. About the Author
    6. About the Reviewer
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    8. Preface
      1. Distinctive features
      2. What this book covers
      3. What you need for this book
      4. Who this book is for
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Getting Started with Spark and GraphX
      1. Downloading and installing Spark 1.4.1
      2. Experimenting with the Spark shell
      3. Getting started with GraphX
        1. Building a tiny social network
          1. Loading the data
          2. The property graph
          3. Transforming RDDs to VertexRDD and EdgeRDD
          4. Introducing graph operations
        2. Building and submitting a standalone application
          1. Writing and configuring a Spark program
          2. Building the program with the Scala Build Tool
          3. Deploying and running with spark-submit
      4. Summary
    10. 2. Building and Exploring Graphs
      1. Network datasets
        1. The communication network
        2. Flavor networks
        3. Social ego networks
      2. Graph builders
        1. The Graph factory method
        2. edgeListFile
        3. fromEdges
        4. fromEdgeTuples
      3. Building graphs
        1. Building directed graphs
        2. Building a bipartite graph
        3. Building a weighted social ego network
      4. Computing the degrees of the network nodes
        1. In-degree and out-degree of the Enron email network
        2. Degrees in the bipartite food network
        3. Degree histogram of the social ego networks
      5. Summary
    11. 3. Graph Analysis and Visualization
      1. Network datasets
      2. The graph visualization
        1. Installing the GraphStream and BreezeViz libraries
        2. Visualizing the graph data
        3. Plotting the degree distribution
      3. The analysis of network connectedness
        1. Finding the connected components
        2. Counting triangles and computing clustering coefficients
      4. The network centrality and PageRank
        1. How PageRank works
        2. Ranking web pages
      5. Scala Build Tool revisited
        1. Organizing build definitions
        2. Managing library dependencies
          1. A preview of the steps
            1. Step 1 – Enable the sbt-assembly plugin
            2. Step 2 – Create a build.sbt file
            3. Step 3 – Declare library dependencies and resolvers
            4. Step 4 – Set up the sbt-assembly plugin
            5. Step 5 – Create the uber JAR
          2. Running tasks with SBT commands
      6. Summary
    12. 4. Transforming and Shaping Up Graphs to Your Needs
      1. Transforming the vertex and edge attributes
        1. mapVertices
        2. mapEdges
        3. mapTriplets
      2. Modifying graph structures
        1. The reverse operator
        2. The subgraph operator
        3. The mask operator
        4. The groupEdges operator
      3. Joining graph datasets
        1. joinVertices
        2. outerJoinVertices
        3. Example – Hollywood movie graph
      4. Data operations on VertexRDD and EdgeRDD
        1. Mapping VertexRDD and EdgeRDD
        2. Filtering VertexRDDs
        3. Joining VertexRDDs
        4. Joining EdgeRDDs
        5. Reversing edge directions
        6. Collecting neighboring information
        7. Example – from food network to flavor pairing
      5. Summary
    13. 5. Creating Custom Graph Aggregation Operators
      1. NCAA College Basketball datasets
      2. The aggregateMessages operator
        1. EdgeContext
        2. Abstracting out the aggregation
        3. Keeping things DRY
        4. Coach wants more numbers
        5. Calculating average points per game
        6. Defense stats – D matters as in direction
      3. Joining average stats into a graph
      4. Performance optimization
      5. The MapReduceTriplets operator
      6. Summary
    14. 6. Iterative Graph-Parallel Processing with Pregel
      1. The Pregel computational model
        1. Example – iterating towards the social equality
      2. The Pregel API in GraphX
      3. Community detection through label propagation
      4. The Pregel implementation of PageRank
      5. Summary
    15. 7. Learning Graph Structures
      1. Community clustering in graphs
        1. Spectral clustering
        2. Power iteration clustering
      2. Applications – music fan community detection
        1. Step 1 – load the data into a Spark graph property
        2. Step 2 – extract the features of nodes
        3. Step 3 – define a similarity measure between two nodes
        4. Step 4 – create an affinity matrix
        5. Step 5 – run k-means clustering on the affinity matrix
        6. Exercise – collaborative clustering through playlists
      3. Summary
    16. A. References
      1. Chapter 2, Building and Exploring Graphs
      2. Chapter 3, Graph Analysis and Visualization
      3. Chapter 7, Learning Graph Structures
    17. Index

Product information

  • Title: Apache Spark Graph Processing
  • Author(s): Rindra Ramamonjison
  • Release date: September 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781784391805