Skip to content

Instantly share code, notes, and snippets.

@mikk-c
Last active September 20, 2018 12:21
Show Gist options
  • Save mikk-c/25b568c6744ad264b59e84fe5b580ffc to your computer and use it in GitHub Desktop.
Save mikk-c/25b568c6744ad264b59e84fe5b580ffc to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#Reading the data \n",
"dataset = \"protein\" #Try with other datasets\n",
"g = nx.read_edgelist(\"data/%s.txt\" %(dataset), delimiter=\"\\t\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#Return the density, clustering coefficient, average clustering coefficient (average of local clustering coefficient of all nodes)\n",
"\n",
"density = nx.density(g)\n",
"global_cc = nx.transitivity(g)\n",
"avg_cc = nx.average_clustering(g)\n",
"print(\"density = %s , CC = %s , Average CC = %s\" % (density,global_cc,avg_cc))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment