08: Affiliation and History#

This week we’ll explore the two special kinds of networks we discussed in class: multipartite networks, which are for more than one kind of node, and multilayer networks, which are for more than one kind of edge.

In a short Jupyter notebook report, complete the following tasks. Don’t simply calculate the answers: make sure you’re fully explaining (in writing) the metrics and visualizations that you generate. Consider the Criteria for Good Reports as a guide. You can create markdown cells with section headers to separate the different sections of the report. Rather than number the report as if you’re answering distinct questions, use the questions as a guide to do some data storytelling, i.e. explain this network’s data in an organized way.

  1. Download an Affiliation network of your choice from the KONECT project datasets. (If you’re unable to unzip these files, download one of the ones available under Sakai Resources.) Load the data into NetworkX and calculate at least 3 kinds of bipartite centrality on this network. Export the data to a .gml file with those measures included. Visualize your bipartite network in nx_altair, using a bipartite layout and using one of your centrality measures as the size of the nodes. What do you learn about the nodes in your network with high centrality?

n.b. Loading this data will require some adjustment of the original data that you downloaded. Refer to our discussion of this from class, and reach out if you have any questions.

  1. Using the same dataset, project your network in a unipartite graph, onto the nodeset of people in your network. Visualize this new network in nx_altair. What information is gained by presenting the network in this way, and how does it help you understand the people in your network? What information is lost?

  2. Download the quaker_edgelist.csv data from the textbook datasets page. This is a historical dynamic/temporal network that shows changing relationships over time. Using this tutorial, create a timeline for this network in Gephi and create a visualization showing changes in the network over time. Include two or three screenshots showing key moments in the network’s history (include the timeline at the bottom of the Gephi window in your screenshots). During what period in time were most of the relationships in this network active? How do you know this?

  3. NetworkX has no functionality for multilayer networks. To work with dynamic and temporal networks, we’ll try out the Teneto library. This week you’ll read the docs and try to work it out yourself, but later I’ll post some basic functions in the the textbook for reference. Load the quaker_edgelist.csv as a dataframe and put it into a Teneto TemporalNetwork object. I’ve included some code here for converting the edgelist into the appropriate form for Teneto, but give it a try yourself first. (You may also need quaker_nodelist.csv for this.) Once you have a temporal network object, calculate temporal degree centrality, fluctuability, and topological overlap. Make sure to calculate these measures using overtime as a parameter. Describe and interpret all of these metrics. Who are the most important people in this network over time, and how consistent is the network over time?

Click here for the Teneto dataprep solution
nodes = pd.read_csv("quaker_nodelist.csv")
all_nodes = nodes.name.to_list()

intervals = range(q[“Start Year”].min(),q[“End Year”].max(),20) new_edges = [] for n,row in q.iterrows(): for i,x in enumerate(intervals): try: if row[“Start Year”] <= x <= row[“End Year”]: new_edges.append({‘i’: all_nodes.index(row[‘Source’]), ‘j’: all_nodes.index(row[‘Target’]), ‘t’: i}) except IndexError: if row[“Start Year”] <= x <= q[“End Year”].max(): new_edges.append({‘i’: row[‘Source ID’], ‘j’: row[‘Target ID’], ‘t’: i})

new_df = pd.DataFrame(new_edges) new_df

  1. Using Teneto’s tnet.plot() function (not nx_altair), create a slice plot of your Quaker network. Interpret this plot fully, and discuss what it showed about your network differently from the Gephi temporal network. [For example, the slice plot function might look like tnet.plot('slice_plot', ax=ax, cmap='Set2') (but you might need additional code to make this work).]

When you’re finished, remove these instructions from the top of the file, leaving only your own writing and code. Export the notebook as an HTML file, check to make sure everything is formatted correctly, and submit your HTML file to Sakai.