Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Gephi Cookbook
Gephi Cookbook

Gephi Cookbook: Over 90 hands-on recipes to master the art of network analysis and visualization with Gephi

eBook
zł59.99 zł158.99
Paperback
zł197.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Gephi Cookbook

Chapter 2. Basic Graph Manipulations

In this chapter, we will cover the following recipes:

  • Generating a random graph
  • Selecting and highlighting nodes in the graph
  • Coloring and sizing nodes in the graph
  • Adding nodes and edges to the graph
  • Editing node attributes in the graph
  • Finding out the shortest path in the graph
  • Setting the edge and label properties
  • Setting basic properties for graphs, nodes, edges, and labels
  • Changing the background color of the graph
  • Generating a heat map for the graph
  • Showing convex hulls for a graph where a hierarchy exists
  • Showing/hiding various parts of the graph
  • Reverting changes in the graph to the original presets
  • Creating a PNG file directly from the graph window in user-specified sizes

Introduction

This chapter teaches you how to perform basic graph manipulations in Gephi. Manipulations such as modifying network structure by adding or deleting nodes and edges, editing node attributes, and applying filters on the network can be very easily done in Gephi, owing to its user-friendly interface.

Generating a random graph

A random graph with n nodes is a graph generated by starting with n nodes with no edges existing between any pair of nodes, and then randomly adding edges between nodes in a probabilistic fashion. This recipe describes the process of generating one such random graph in Gephi.

How to do it…

The steps to generate a random graph with n nodes are as follows:

  1. Click on File in the menu bar.
  2. Choose Generate in the drop-down menu.
  3. Choose Random Graph in the extended menu. You'll see the following pop-up window on the screen:
    How to do it…
  4. In the Number of nodes textbox, enter the number of nodes (n) that you want the random graph to have.
  5. In the Wiring probability textbox, enter the probability (p), according to where you would like the edges to be added between different pairs of nodes in the random graph. A low wiring probability will result in a regular lattice. On the other hand, the higher the wiring probability is, the more random the resulting graph will be.
  6. Click on OK....

Selecting and highlighting nodes in the graph

In this recipe, you will learn how to selectively pick up specific nodes in the graph and how to highlight them for closer study.

How to do it…

There are two different ways in which nodes can be selected in Gephi: direct selection and rectangle selection. Here's how we go about selecting the nodes in Gephi:

  1. To directly select a node and view its neighbors/adjacent nodes, click on the little arrow button towards the upper-left corner of the Graph panel, as shown in the following screenshot:
    How to do it…
  2. Navigate to the node that you want to highlight and place the arrow on the node. You will notice that the node on which you have placed the arrow, along with the neighboring nodes and the edges connecting them, has become highlighted while the other nodes are dimmed. This is shown in the following screenshot:
    How to do it…
  3. To select a node using rectangle selection, click on the button with the little rectangle depicted on it towards the upper-left corner of the...

Coloring and sizing nodes in the graph

Sometimes, while studying the properties of a network, we need to manually alter some of the attributes of the nodes, such as their color and size. This section explains how to achieve this.

How to do it…

The following steps illustrate how to resize individual nodes in the graph:

  1. Click on the diamond-shaped button in the toolbar placed on the left-hand side of the Graph panel. The mouse pointer, when placed over it, should show a descriptor textbox that reads Sizer.
  2. Click on the node that you want to resize and while holding the mouse button, drag the mouse vertically upwards or downwards. Dragging the mouse upwards will increase the size of the node and dragging it downwards will decrease the size.
  3. If the resized node now hides a part of the graph that you otherwise want to continue looking at, click on the button in the same toolbar with a hand symbol on it. Placing the mouse pointer on this button should show up a descriptor textbox that reads...

Adding nodes and edges to the graph

Gephi allows its users to alter graphs on-the-fly by offering capabilities such as adding node(s) or edge(s) to the graph in just one click. This recipe discusses how to carry out these actions.

How to do it…

The following steps illustrate the procedure to add a new node to the graph:

  1. Click on the pencil-shaped button in the toolbar, placed vertically on the upper-left side of the edge of the Graph panel. When a mouse pointer is placed on the icon, it should show a descriptor textbox that reads Node Pencil.
  2. In the upper-right corner of the Graph panel, choose the color that you would like to assign to the node and set the desired size for it.
  3. Now, click on the area of the Graph panel where you want to place the new node. This will create a new node with the selected color and size, as shown in the following screenshot:
    How to do it…

Follow these steps to add a new edge to the graph:

  1. Click on the pencil-shaped button in the toolbar that is placed vertically on the upper...

Editing node attributes in the graph

There might be cases where one would like to change some attributes for specific nodes manually. Gephi offers a very easy way to do so. In this recipe, we will discuss how, with just a single click, you can alter node attributes such as size, position, color, label, and so on.

How to do it…

The following steps illustrate the way to change node attributes such as size, position, color, label, and so on.

  1. Click on the button with an arrow and a question mark on it that is placed last on the toolbar located vertically on the upper-left edge of the Graph panel. When a mouse pointer is placed over this button, it should read Edit-Edit node attributes.
  2. Now click on the node whose attributes you want to alter.
  3. This opens a new panel titled Edit on the upper-left corner of the screen.
  4. Click on the attribute(s) that you want to modify and assign new value(s).

There's more…

You cannot modify attributes such as ID, since those are unique values.

Introduction


This chapter teaches you how to perform basic graph manipulations in Gephi. Manipulations such as modifying network structure by adding or deleting nodes and edges, editing node attributes, and applying filters on the network can be very easily done in Gephi, owing to its user-friendly interface.

Generating a random graph


A random graph with n nodes is a graph generated by starting with n nodes with no edges existing between any pair of nodes, and then randomly adding edges between nodes in a probabilistic fashion. This recipe describes the process of generating one such random graph in Gephi.

How to do it…

The steps to generate a random graph with n nodes are as follows:

  1. Click on File in the menu bar.

  2. Choose Generate in the drop-down menu.

  3. Choose Random Graph in the extended menu. You'll see the following pop-up window on the screen:

  4. In the Number of nodes textbox, enter the number of nodes (n) that you want the random graph to have.

  5. In the Wiring probability textbox, enter the probability (p), according to where you would like the edges to be added between different pairs of nodes in the random graph. A low wiring probability will result in a regular lattice. On the other hand, the higher the wiring probability is, the more random the resulting graph will be.

  6. Click on OK. This generates...

Selecting and highlighting nodes in the graph


In this recipe, you will learn how to selectively pick up specific nodes in the graph and how to highlight them for closer study.

How to do it…

There are two different ways in which nodes can be selected in Gephi: direct selection and rectangle selection. Here's how we go about selecting the nodes in Gephi:

  1. To directly select a node and view its neighbors/adjacent nodes, click on the little arrow button towards the upper-left corner of the Graph panel, as shown in the following screenshot:

  2. Navigate to the node that you want to highlight and place the arrow on the node. You will notice that the node on which you have placed the arrow, along with the neighboring nodes and the edges connecting them, has become highlighted while the other nodes are dimmed. This is shown in the following screenshot:

  3. To select a node using rectangle selection, click on the button with the little rectangle depicted on it towards the upper-left corner of the Graph panel:

  4. Place...

Coloring and sizing nodes in the graph


Sometimes, while studying the properties of a network, we need to manually alter some of the attributes of the nodes, such as their color and size. This section explains how to achieve this.

How to do it…

The following steps illustrate how to resize individual nodes in the graph:

  1. Click on the diamond-shaped button in the toolbar placed on the left-hand side of the Graph panel. The mouse pointer, when placed over it, should show a descriptor textbox that reads Sizer.

  2. Click on the node that you want to resize and while holding the mouse button, drag the mouse vertically upwards or downwards. Dragging the mouse upwards will increase the size of the node and dragging it downwards will decrease the size.

  3. If the resized node now hides a part of the graph that you otherwise want to continue looking at, click on the button in the same toolbar with a hand symbol on it. Placing the mouse pointer on this button should show up a descriptor textbox that reads Drag.

  4. Now...

Adding nodes and edges to the graph


Gephi allows its users to alter graphs on-the-fly by offering capabilities such as adding node(s) or edge(s) to the graph in just one click. This recipe discusses how to carry out these actions.

How to do it…

The following steps illustrate the procedure to add a new node to the graph:

  1. Click on the pencil-shaped button in the toolbar, placed vertically on the upper-left side of the edge of the Graph panel. When a mouse pointer is placed on the icon, it should show a descriptor textbox that reads Node Pencil.

  2. In the upper-right corner of the Graph panel, choose the color that you would like to assign to the node and set the desired size for it.

  3. Now, click on the area of the Graph panel where you want to place the new node. This will create a new node with the selected color and size, as shown in the following screenshot:

Follow these steps to add a new edge to the graph:

  1. Click on the pencil-shaped button in the toolbar that is placed vertically on the upper-left...

Editing node attributes in the graph


There might be cases where one would like to change some attributes for specific nodes manually. Gephi offers a very easy way to do so. In this recipe, we will discuss how, with just a single click, you can alter node attributes such as size, position, color, label, and so on.

How to do it…

The following steps illustrate the way to change node attributes such as size, position, color, label, and so on.

  1. Click on the button with an arrow and a question mark on it that is placed last on the toolbar located vertically on the upper-left edge of the Graph panel. When a mouse pointer is placed over this button, it should read Edit-Edit node attributes.

  2. Now click on the node whose attributes you want to alter.

  3. This opens a new panel titled Edit on the upper-left corner of the screen.

  4. Click on the attribute(s) that you want to modify and assign new value(s).

There's more…

You cannot modify attributes such as ID, since those are unique values.

Finding out the shortest path in the graph


Finding the shortest path in a graph is one of the problems that is widely encountered in many different situations across many different domains. This is one of the fundamental problems in graph theory. It has applications in domains such as computer networks, inventory optimization, flow networks, and so on. In this recipe, we will learn how to compute and visualize the shortest path in a graph in Gephi.

Getting ready

Load a pre-existing network in which you would like to find the shortest path, such as Les Misérables, or create one.

How to do it…

To compute and visualize the shortest path for a pair of nodes in a network, follow these steps:

  1. Click on the button with an airplane symbol on it in the vertically placed left-hand side toolbar in the Graph panel. When placed over this button, the mouse pointer displays a descriptor textbox that reads Shortest Path.

  2. Now click on the source node in the graph from where the path should start.

  3. Select the target...

Setting the edge and label properties


Gephi offers functionality to set up edge and label properties such as edge weight, edge color, label weight, label color, and so on. These functionalities will be discussed in this recipe.

How to do it…

To set edge and label properties explicitly, follow these steps:

  1. Load the Les Misérables graph in Gephi.

  2. Click on the upward-pointing arrow located at the bottom-right corner of the Graph panel to expand a new panel.

  3. In that panel, click on the Labels tab.

  4. Check the checkbox located next to Nodes. This will display all the node labels.

  5. The first button we will discuss defines how the edges will be colored. This is the button with a line segment and a mini-rainbow-like structure as its icon placed at the fourth position in the horizontal toolbar located towards the bottom of the Graph panel. Hovering the mouse pointer on top of it should show a descriptor textbox that reads Edges have source node color.

  6. When toggled on, this will result in the edges taking the...

Setting basic properties for graphs, nodes, edges, and labels


Apart from what has been discussed so far in this chapter, Gephi also offers some additional options for configuring the basic properties of the graphs, nodes, edges, and labels. This section discusses these functionalities.

Getting ready

Load the Les Misérables graph in Gephi.

How to do it…

In the following steps, we will discuss various functionalities offered by Gephi to set the basic properties of graphs, nodes, edges, and labels.

  1. Click on the upward-pointing arrow located in the bottom-right corner of the Graph panel to expand a new toolbar with four tabs: Global, Nodes, Edges, and Labels.

  2. Click on the Global tab.

  3. Click on the button next to Background Color to open a color palette window where you can select the background for the graph.

  4. The Autoselect neighbor checkbox is used to turn the toggle on and off for selecting the neighbors when a node is selected.

  5. Move the Zoom slider back and forth to zoom-in and zoom-out of the graph...

Left arrow icon Right arrow icon

Description

If you want to learn network analysis and visualization along with graph concepts from scratch, then this book is for you. This is ideal for those of you with little or no understanding of Gephi and this domain, but will also be beneficial for those interested in expanding their knowledge and experience.

Who is this book for?

If you want to learn network analysis and visualization along with graph concepts from scratch, then this book is for you. This is ideal for those of you with little or no understanding of Gephi and this domain, but will also be beneficial for those interested in expanding their knowledge and experience.

What you will learn

  • Install and configure Gephi on your system and understand its various features
  • Perform basic manipulation and exploration tasks on graphs
  • Understand various layout algorithms present by default in Gephi and the principles behind them
  • Explore the properties of graphical networks using numerous filters and statistical metrics available in Gephi
  • Import graph data from different sources and manipulate it directly in tabular formats
  • Use realworld datasets to better understand network analysis

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 27, 2015
Length: 296 pages
Edition : 1st
Language : English
ISBN-13 : 9781783987405
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : May 27, 2015
Length: 296 pages
Edition : 1st
Language : English
ISBN-13 : 9781783987405
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 593.97
Gephi Cookbook
zł197.99
Mastering Gephi Network Visualization
zł197.99
Neo4j Cookbook
zł197.99
Total 593.97 Stars icon

Table of Contents

11 Chapters
1. Getting Started with Gephi Chevron down icon Chevron up icon
2. Basic Graph Manipulations Chevron down icon Chevron up icon
3. Using Graph Layout Algorithms Chevron down icon Chevron up icon
4. Working with Partition and Ranking Algorithms Chevron down icon Chevron up icon
5. Running Metrics, Filters, and Timelines Chevron down icon Chevron up icon
6. Working in the Data Laboratory Mode Chevron down icon Chevron up icon
7. Getting Graphs and Networks Ready for Preview Chevron down icon Chevron up icon
8. Exploring Dynamic and Multilevel Graphs Chevron down icon Chevron up icon
9. Getting Real-world Graph Datasets Chevron down icon Chevron up icon
10. Exploring Some Useful Gephi Plugins Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(1 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
PierreR May 18, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Un livre qui vous permettra de prendre en main facilement le logiciel de Graphe Gephi. Avec beaucoup de d'exemples pratiques et clairs. Je me sers de Gephi pour faire des Graphes de Sites Web.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.