Skip to content

Commit

Permalink
Space out cells
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-rliu committed Sep 30, 2024
1 parent dd87c43 commit 74da95f
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions notebooks/demo/nxcg_wikipedia_e2e.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,77 @@
" sep=\" \",\n",
" names=[\"src\", \"dst\"],\n",
" dtype=\"int32\",\n",
")\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"# Read the Wikipedia Page metadata from `nodedata_csv`\n",
"nodedata_df = pd.read_csv(\n",
" nodedata_csv,\n",
" sep=\"\\t\",\n",
" names=[\"nodeid\", \"title\"],\n",
" dtype={\"nodeid\": \"int32\", \"title\": \"str\"},\n",
")\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"# Create a NetworkX graph from the connectivity info\n",
"G = nx.from_pandas_edgelist(\n",
" edgelist_df,\n",
" source=\"src\",\n",
" target=\"dst\",\n",
" create_using=nx.DiGraph,\n",
")\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"# Run pagerank on NetworkX\n",
"nx_pr_vals = nx.pagerank(G)\n",
"nx_pr_vals = nx.pagerank(G)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"# Create a DataFrame containing the results\n",
"pagerank_df = pd.DataFrame({\n",
" \"nodeid\": nx_pr_vals.keys(),\n",
" \"pagerank\": nx_pr_vals.values()\n",
"})\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"# Add NetworkX results to `nodedata` as new columns\n",
"nodedata_df = nodedata_df.merge(pagerank_df, how=\"left\", on=\"nodeid\")\n",
Expand Down

0 comments on commit 74da95f

Please sign in to comment.