Python Tutorial: Intermediate Network Analysis in Python | Definitions & basic recap
Skills:
Python for Data60%
Key Takeaways
The video tutorial covers intermediate network analysis in Python using the NetworkX library, recapping definitions and basic concepts of graphs and networks, including directed and undirected graphs, and introducing the NXVis package for visualization.
Full Transcript
hi I'm Eric and I'm a computational biological engineer and I'll be your instructor for this course to get started let's start by recapping some definitions recall that a network which is also known as a graph is comprised of two sets a set of nodes and a set of edges we often draw graphs as circles joined by lines where the circles represent some real-world entity such as individuals in a social network and the lines denote some relationship between the entities such as being connected as friends in the social network a graph can be directed or undirected previously we saw some examples of undirected graphs such as Facebook if I request to connect with another person on Facebook once the other person accepts the friend request we immediately connect and no direction is unapplied thus it is an undirected graph on the other hand if we look at the Twitter network I may choose to follow another user but that user may not necessarily follow me back in this way the Twitter social network is a directed Network in Python there is a package called Network X which contains a library of classes and functions for the creation analysis and manipulation of graphs in the previous course we showed you some of the basics of the network X API and applied those functions to case studies let's take a quick look at the basics of the API to refresh your memory as always we must first import Network X into our Python session suppose we had a graph G that already exists in memory if I want to know how many nodes exist in that graph I can call on jeez my third nodes which will return a list of every node in the graph the analogous method edges also exists because both nodes and edges return a list it is thus possible to get the length of each of those elements Len G notes gives us the number of nodes in the graph and Len G dot edges gives us the number of edges in the graph using these two lines of code we can start describing a graphs basic statistics if you remember there were multiple types of graphs and we can check the type of the graph by doing type G which in this case is a regular graph object other graph types include digraph multi graph and multi diagraph previously you also learned about the NX vias package which is a package I wrote that provides a simple API for the visualization of large complex networks in a rational fashion rational visualizations prioritized the nodes placement this allows us to create beautiful visualizations such as the matrix plot the arc plot the circo's plot and the hive plot we will be using the circles plot the most in this course as I personally think that it has the best combination of aesthetics and functionality to use the circo's plot you must first import NX vis and matplotlib spy plot as PLT then you can instantiate a new plot object passing in the graph G after that you'll have to call the dot draw method of the plot object finally call the PLT dot show function to get the plot to be drawn to screen yielding beautiful network diagrams like the ones below once you're done with the coming warm-up exercises we'll come back to explore a new topic bipartite graphs have fun with the exercises
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/intermediate-network-analysis-in-python at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Hi! I'm Eric, and I'm a computational biological engineer from MIT, and I'll be your instructor for this course!
We'll start with some definitions.
Recall that a network, which is also known as a graph, is comprised of two sets: a set of nodes, and a set of edges. We often draw graphs as “circles joined by lines”, where the circles represent some real-world entity, such as individuals in a social network, and the lines denote some relationship between the entities, such as being connected as friends in the social network.
A graph can be directed or undirected. Previously, we saw some examples of undirected graphs, such as Facebook - if I request to connect with another person on Facebook, once the other person accepts the Friend Request, we immediately connect, and no direction is implied, thus it is an “Undirected” graph.
On the other hand, if we look at the Twitter network, I may choose to Follow another user, but that user may not necessarily follow me back. In this way, the Twitter social network is a “Directed” network.
In Python, there is a package called NetworkX, which contains a library of classes and functions for the creation, analysis, and manipulation of graphs. In the previous course, we showed you some of the basics of the NetworkX API, and applied those functions to case studies.
Let’s take a quick look at the basics of the API to refresh your memory.
As always, we must first import NetworkX into our Python session.
Suppose we had a graph G that already exists in memory. If I want to know how many nodes exist in that graph, I can call on G’s method “dot nodes”, which will return a list of every node in the graph. The analogous method dot edges also exists.
Because both =dot nodes and dot edges return a list, it
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
More on: Python for Data
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Applying Scalability in Backend (CodeBuddy)
Medium · LLM
Why Every Backend Developer Should Learn Nginx Before Going to Production
Medium · DevOps
Connecting Frontend to Backend: A Backend Engineer’s Reality Check
Medium · Programming
Build Secure Authentication System Using Access and Refresh Tokens
Medium · Python
🎓
Tutor Explanation
DeepCamp AI