diff options
Diffstat (limited to 'tutorial.ipynb')
-rw-r--r-- | tutorial.ipynb | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/tutorial.ipynb b/tutorial.ipynb index bd27f376..40f853a5 100644 --- a/tutorial.ipynb +++ b/tutorial.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "e3b4c6cb", + "id": "7ccab446", "metadata": {}, "source": [ "## Tutorial\n", @@ -17,7 +17,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5576467a", + "id": "71ea016d", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "2f9d4265", + "id": "aa8ac53f", "metadata": {}, "source": [ "By definition, a `Graph` is a collection of nodes (vertices) along with\n", @@ -47,7 +47,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0a791bd4", + "id": "0980a693", "metadata": {}, "outputs": [], "source": [ @@ -56,7 +56,7 @@ }, { "cell_type": "markdown", - "id": "c9fbb085", + "id": "d2e028f1", "metadata": {}, "source": [ "or add nodes from any [iterable](https://docs.python.org/3/glossary.html#term-iterable) container, such as a list" @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a55d12ce", + "id": "88d2ec03", "metadata": {}, "outputs": [], "source": [ @@ -74,7 +74,7 @@ }, { "cell_type": "markdown", - "id": "722f5149", + "id": "fc693aa8", "metadata": {}, "source": [ "You can also add nodes along with node\n", @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c886466a", + "id": "e27a376e", "metadata": {}, "outputs": [], "source": [ @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "01b57622", + "id": "7c54e3d0", "metadata": {}, "source": [ "`G` now contains the nodes of `H` as nodes of `G`.\n", @@ -116,7 +116,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5dfd7b46", + "id": "f46a7b22", "metadata": {}, "outputs": [], "source": [ @@ -125,7 +125,7 @@ }, { "cell_type": "markdown", - "id": "15fb720b", + "id": "d51b1b17", "metadata": {}, "source": [ "The graph `G` now contains `H` as a node. This flexibility is very powerful as\n", @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54dc3160", + "id": "9531ea66", "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "172498d6", + "id": "fd9ba5a4", "metadata": {}, "source": [ "by adding a list of edges," @@ -163,7 +163,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21364aac", + "id": "744c9caa", "metadata": {}, "outputs": [], "source": [ @@ -172,7 +172,7 @@ }, { "cell_type": "markdown", - "id": "622e5aac", + "id": "be753840", "metadata": {}, "source": [ "or by adding any ebunch of edges. An *ebunch* is any iterable\n", @@ -185,7 +185,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7037d73c", + "id": "4b2cbb84", "metadata": {}, "outputs": [], "source": [ @@ -194,7 +194,7 @@ }, { "cell_type": "markdown", - "id": "1d6a97bc", + "id": "6feeafeb", "metadata": {}, "source": [ "There are no complaints when adding existing nodes or edges. For example,\n", @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4b23410e", + "id": "c0dbd368", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ }, { "cell_type": "markdown", - "id": "1f39f96d", + "id": "537f3ffc", "metadata": {}, "source": [ "we add new nodes/edges and NetworkX quietly ignores any that are\n", @@ -223,7 +223,7 @@ { "cell_type": "code", "execution_count": null, - "id": "83130d08", + "id": "46722cac", "metadata": {}, "outputs": [], "source": [ @@ -237,7 +237,7 @@ }, { "cell_type": "markdown", - "id": "a9eba233", + "id": "db505c0e", "metadata": {}, "source": [ "At this stage the graph `G` consists of 8 nodes and 3 edges, as can be seen by:" @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "465cf2c9", + "id": "a2c93eb4", "metadata": {}, "outputs": [], "source": [ @@ -257,7 +257,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7823b21f", + "id": "83185796", "metadata": {}, "outputs": [], "source": [ @@ -272,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "64aa0773", + "id": "445b92d4", "metadata": {}, "source": [ "# Examining elements of a graph\n", @@ -292,7 +292,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3ff762e2", + "id": "5245b501", "metadata": {}, "outputs": [], "source": [ @@ -304,7 +304,7 @@ }, { "cell_type": "markdown", - "id": "a4b5de2d", + "id": "71f9a0a3", "metadata": {}, "source": [ "One can specify to report the edges and degree from a subset of all nodes\n", @@ -316,7 +316,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12bcbc1a", + "id": "3f1923c8", "metadata": {}, "outputs": [], "source": [ @@ -326,7 +326,7 @@ }, { "cell_type": "markdown", - "id": "32d8fd07", + "id": "3f6ee189", "metadata": {}, "source": [ "# Removing elements from a graph\n", @@ -343,7 +343,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c2b6b314", + "id": "403ea631", "metadata": {}, "outputs": [], "source": [ @@ -355,7 +355,7 @@ }, { "cell_type": "markdown", - "id": "d96f2e94", + "id": "c441bb61", "metadata": {}, "source": [ "# Using the graph constructors\n", @@ -370,7 +370,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9afdca65", + "id": "a64e20fe", "metadata": {}, "outputs": [], "source": [ @@ -387,7 +387,7 @@ }, { "cell_type": "markdown", - "id": "2b87b39b", + "id": "3b4797c3", "metadata": {}, "source": [ "# What to use as nodes and edges\n", @@ -416,7 +416,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5031e469", + "id": "6398381f", "metadata": {}, "outputs": [], "source": [ @@ -428,7 +428,7 @@ }, { "cell_type": "markdown", - "id": "0de80526", + "id": "a78f4789", "metadata": {}, "source": [ "You can get/set the attributes of an edge using subscript notation\n", @@ -438,7 +438,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29d1d4a9", + "id": "7bd5354e", "metadata": {}, "outputs": [], "source": [ @@ -450,7 +450,7 @@ }, { "cell_type": "markdown", - "id": "57eed5af", + "id": "1951d601", "metadata": {}, "source": [ "Fast examination of all (node, adjacency) pairs is achieved using\n", @@ -461,7 +461,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7ac3f870", + "id": "296db177", "metadata": {}, "outputs": [], "source": [ @@ -475,7 +475,7 @@ }, { "cell_type": "markdown", - "id": "5e6fd308", + "id": "293bf78c", "metadata": {}, "source": [ "Convenient access to all edges is achieved with the edges property." @@ -484,7 +484,7 @@ { "cell_type": "code", "execution_count": null, - "id": "653c6da2", + "id": "08403ca8", "metadata": {}, "outputs": [], "source": [ @@ -495,7 +495,7 @@ }, { "cell_type": "markdown", - "id": "93b10672", + "id": "e61d611a", "metadata": {}, "source": [ "# Adding attributes to graphs, nodes, and edges\n", @@ -517,7 +517,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6f783c7d", + "id": "2bfc4734", "metadata": {}, "outputs": [], "source": [ @@ -527,7 +527,7 @@ }, { "cell_type": "markdown", - "id": "54b3c521", + "id": "bfcd2122", "metadata": {}, "source": [ "Or you can modify attributes later" @@ -536,7 +536,7 @@ { "cell_type": "code", "execution_count": null, - "id": "edcb6c37", + "id": "17d63f27", "metadata": {}, "outputs": [], "source": [ @@ -546,7 +546,7 @@ }, { "cell_type": "markdown", - "id": "840049be", + "id": "234658ab", "metadata": {}, "source": [ "# Node attributes\n", @@ -557,7 +557,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9b3928cb", + "id": "bf6a969f", "metadata": {}, "outputs": [], "source": [ @@ -570,7 +570,7 @@ }, { "cell_type": "markdown", - "id": "c4184226", + "id": "70449c66", "metadata": {}, "source": [ "Note that adding a node to `G.nodes` does not add it to the graph, use\n", @@ -585,7 +585,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37effb50", + "id": "5327a56d", "metadata": {}, "outputs": [], "source": [ @@ -598,7 +598,7 @@ }, { "cell_type": "markdown", - "id": "a26fb909", + "id": "d3bbc698", "metadata": {}, "source": [ "The special attribute `weight` should be numeric as it is used by\n", @@ -619,7 +619,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a83a5aff", + "id": "7686cfe1", "metadata": {}, "outputs": [], "source": [ @@ -633,7 +633,7 @@ }, { "cell_type": "markdown", - "id": "a8710f62", + "id": "0750c9c6", "metadata": {}, "source": [ "Some algorithms work only for directed graphs and others are not well\n", @@ -646,7 +646,7 @@ { "cell_type": "code", "execution_count": null, - "id": "04f47562", + "id": "0b8346a7", "metadata": {}, "outputs": [], "source": [ @@ -655,7 +655,7 @@ }, { "cell_type": "markdown", - "id": "4b4957fd", + "id": "b51c8e14", "metadata": {}, "source": [ "# Multigraphs\n", @@ -675,7 +675,7 @@ { "cell_type": "code", "execution_count": null, - "id": "34c5a178", + "id": "fc17806b", "metadata": {}, "outputs": [], "source": [ @@ -693,7 +693,7 @@ }, { "cell_type": "markdown", - "id": "ffaf9b1d", + "id": "4e97bc06", "metadata": {}, "source": [ "# Graph generators and graph operations\n", @@ -713,7 +713,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e5b54464", + "id": "648fcb02", "metadata": {}, "outputs": [], "source": [ @@ -725,7 +725,7 @@ }, { "cell_type": "markdown", - "id": "43db4093", + "id": "75e3bbba", "metadata": {}, "source": [ "# 4. Using a stochastic graph generator, e.g,\n", @@ -736,7 +736,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15250e99", + "id": "dcfb0edf", "metadata": {}, "outputs": [], "source": [ @@ -748,7 +748,7 @@ }, { "cell_type": "markdown", - "id": "afa3e227", + "id": "2a88b3d3", "metadata": {}, "source": [ "# 5. Reading a graph stored in a file using common graph formats\n", @@ -760,7 +760,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3fd7fa9a", + "id": "18fa7468", "metadata": {}, "outputs": [], "source": [ @@ -770,7 +770,7 @@ }, { "cell_type": "markdown", - "id": "464f1849", + "id": "f3ec0545", "metadata": {}, "source": [ "For details on graph formats see Reading and writing graphs\n", @@ -785,7 +785,7 @@ { "cell_type": "code", "execution_count": null, - "id": "48f96c72", + "id": "1236e5b7", "metadata": {}, "outputs": [], "source": [ @@ -799,7 +799,7 @@ }, { "cell_type": "markdown", - "id": "9e5c6eb4", + "id": "17248966", "metadata": {}, "source": [ "Some functions with large output iterate over (node, value) 2-tuples.\n", @@ -809,7 +809,7 @@ { "cell_type": "code", "execution_count": null, - "id": "97eb312f", + "id": "89719c2f", "metadata": {}, "outputs": [], "source": [ @@ -819,7 +819,7 @@ }, { "cell_type": "markdown", - "id": "933b6776", + "id": "b6625f86", "metadata": {}, "source": [ "See Algorithms for details on graph algorithms\n", @@ -838,7 +838,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ce4fd906", + "id": "163cad99", "metadata": {}, "outputs": [], "source": [ @@ -847,7 +847,7 @@ }, { "cell_type": "markdown", - "id": "340778b2", + "id": "2060a04e", "metadata": {}, "source": [ "To test if the import of `nx_pylab` was successful draw `G`\n", @@ -857,7 +857,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5729a65c", + "id": "674713cf", "metadata": {}, "outputs": [], "source": [ @@ -870,7 +870,7 @@ }, { "cell_type": "markdown", - "id": "3839a528", + "id": "c4ffb67e", "metadata": {}, "source": [ "when drawing to an interactive display. Note that you may need to issue a\n", @@ -880,7 +880,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6478a32f", + "id": "930f5359", "metadata": {}, "outputs": [], "source": [ @@ -889,7 +889,7 @@ }, { "cell_type": "markdown", - "id": "8cd647f8", + "id": "7bbdb213", "metadata": {}, "source": [ "command if you are not using matplotlib in interactive mode." @@ -898,7 +898,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e89f272c", + "id": "29427b11", "metadata": {}, "outputs": [], "source": [ @@ -919,7 +919,7 @@ }, { "cell_type": "markdown", - "id": "04d93eaf", + "id": "fc153443", "metadata": {}, "source": [ "You can find additional options via `draw_networkx()` and\n", @@ -930,7 +930,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e494ea7f", + "id": "ec75cd12", "metadata": {}, "outputs": [], "source": [ @@ -941,7 +941,7 @@ }, { "cell_type": "markdown", - "id": "55bcbc79", + "id": "f6eada6e", "metadata": {}, "source": [ "To save drawings to a file, use, for example" @@ -950,7 +950,7 @@ { "cell_type": "code", "execution_count": null, - "id": "41b4d36e", + "id": "589f977d", "metadata": {}, "outputs": [], "source": [ @@ -960,7 +960,7 @@ }, { "cell_type": "markdown", - "id": "1c61855f", + "id": "6da45806", "metadata": {}, "source": [ "This function writes to the file `path.png` in the local directory. If Graphviz and\n", @@ -973,7 +973,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e72d52c5", + "id": "5ad73987", "metadata": {}, "outputs": [], "source": [ @@ -985,7 +985,7 @@ }, { "cell_type": "markdown", - "id": "7209e1c5", + "id": "02850e5d", "metadata": {}, "source": [ "See Drawing for additional details." |