Skip to content

Commit

Permalink
lab04
Browse files Browse the repository at this point in the history
  • Loading branch information
yy committed Jan 29, 2024
1 parent ee94796 commit baf5ec9
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
87 changes: 87 additions & 0 deletions docs/m04-weakties/lab04.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Network visualization assignment\n",
"\n",
"<div style=\"display: flex; align-items: center;\">\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/yy/netsci-course/blob/master/docs/m04-/lab04.ipynb\">\n",
" <img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" style=\"vertical-align: -8px; margin-right: 10px;\" />\n",
" Open this notebook in Google Colab\n",
" </a>\n",
"</div>\n",
"\n",
"\n",
"<div style=\"display: flex; align-items: center;\">\n",
" <a href=\"https://raw.githubusercontent.com/yy/netsci-course/master/docs/m04-/lab04.ipynb\" download>\n",
" <img src=\"http://yyahn.com/netsci-course/images/download_icon.png\" style=\"vertical-align: -8px; margin-right: 10px;\" />\n",
" Download this notebook (File -> Save As)\n",
" </a>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this assignment, you will play with network visualization tools: Gephi and Cytoscape. Both software can not only visualize networks but also analyze them to some extent. You can use either one of them, but feel free to play with both. You may want to try Gephi first, and then Cytoscape if you have trouble installing Gephi.\n",
"\n",
"<img src=\"https://gephi.org/images/logo.png\" alt=\"Gephi logo\" style=\"height:100px;\"/>\n",
"<img src=\"https://cytoscape.org/images/logo/Cytoscape_3.png\" alt=\"Cytoscape logo\" style=\"height:100px;\"/>\n",
"\n",
"## Gephi\n",
"\n",
"Gephi became popular with its fast layout algorithms and powerful functionalities. However, it is currently not well maintained. As a result, the installation can be problematic, particularly in recent systems. There are some troubleshooting tips in the [course wiki](https://github.com/yy/netsci-course/wiki/Gephi).\n",
"\n",
"You can download and install Gephi: <https://gephi.org/>. The following is a tutorial made by a previous AI, Nathaniel.\n",
"\n",
"[Gephi tutorial](https://www.youtube.com/watch?v=PAoRKtUfUkA)\n",
"\n",
"Depending upon what version of Gephi you use the location of some buttons and tabs may vary, but the general functionality is roughly the same. If you want to know more about Gephi or what file formats it can read/write you can visit their [documentation page](https://gephi.org/users/).\n",
"\n",
"## Cytoscape\n",
"\n",
"As you can see from the name, Cytoscape is more geared towards biological networks because it was developed for biological network analysis. Still, it can visualize all kinds of networks.\n",
"\n",
"Additionally, it does not have many built-in network analysis functionalities. Instead it uses plug-in system and many plug-ins can be installed and used.\n",
"\n",
"Cytoscape is sustained by a larger community and federal funding, so it is more stable than Gephi in many ways. You can download it at [http://www.cytoscape.org/](http://www.cytoscape.org/) and check out the tutorials at: [https://github.com/cytoscape/cytoscape-tutorials/wiki](https://github.com/cytoscape/cytoscape-tutorials/wiki).\n",
"\n",
"## Assignment\n",
"\n",
"We'll use the Les Miserables graph, which can be downloaded from: [http://www-personal.umich.edu/~mejn/netdata/](http://www-personal.umich.edu/~mejn/netdata/). This site has other graphs which you can download. They are already in a format that Gephi or Cytoscape will recognize (`.net`, `.gexf`, `.gml`, etc).\n",
"\n",
"Once you have the Les Miserables graph do the following:\n",
"\n",
"1. Load the graph into Gephi/Cytoscape as an undirected graph.\n",
"2. Calculate and record the number of nodes, number of edges, average degree, average clustering coefficient, and average path length of the graph.\n",
"3. Save a plot of the degree distribution of the nodes. Note: if you use Cytoscape, you may need to do this step in networkx.\n",
"4. Then, select a graph layout that you think best visualizes the graph and save it.\n",
"5. Create a new Jupyter notebook and use the [random graph generator tool](https://networkx.github.io/documentation/stable/reference/generated/networkx.generators.random_graphs.erdos_renyi_graph.html) introduced in the last assignment to create a random graph with the same number of nodes and about the same average degree and number of edges as the real graph. Please set the random seed as `seed=42`.\n",
"6. Save this random graph to a file format that Gephi/Cytoscape can read (see [this page](https://networkx.github.io/documentation/stable/reference/readwrite/index.html) for Networkx read/write functions) and perform steps 1-4 with this new graph. You can save it as pajek (.net), gml, or gexf.\n",
"\n",
"You should then answer the following questions:\n",
"\n",
"1. How do the degree distributions of the real graph and random graph compare? Explain any differences or similarities you see and consider why they might exist.\n",
"2. Is the real graph more clustered or less than the random one? What might this tell you about the organizing principles of the real graph?\n",
"3. Does the real graph exhibit the small-world property?\n",
"\n",
"When complete, compile your results, figures, and analysis into a `.pdf` file and upload that, along with the Jupyter notebook you used to generate the random graph exported to a `.html` file.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,7 @@ nav:
- m02-friendship_paradox/lab02.ipynb
- "Module 3: What a small world!":
- m03-smallworld/lab03.ipynb
- "Module 4: Strength of weak ties":
- m04-weakties/lab04.ipynb
- "Resources":
- resources/index.md

0 comments on commit baf5ec9

Please sign in to comment.