Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > e5ddaa4c8aef3b801d60a051db101461 > files > 1401

python-networkx-1.8.1-3.mga4.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>MultiGraph - Undirected graphs with self loops and parallel edges &mdash; NetworkX 1.8.1 documentation</title>
    
    <link rel="stylesheet" href="../_static/networkx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.8.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within NetworkX 1.8.1 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="top" title="NetworkX 1.8.1 documentation" href="../index.html" />
    <link rel="up" title="Graph types" href="classes.html" />
    <link rel="next" title="__init__" href="generated/networkx.MultiGraph.__init__.html" />
    <link rel="prev" title="reverse" href="generated/networkx.DiGraph.reverse.html" /> 
  </head>
  <body>
<div style="color: black;background-color: white; font-size: 3.2em; text-align: left; padding: 15px 10px 10px 15px">
NetworkX
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="generated/networkx.MultiGraph.__init__.html" title="__init__"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="generated/networkx.DiGraph.reverse.html" title="reverse"
             accesskey="P">previous</a> |</li>
        <li><a href="http://networkx.github.com/">NetworkX Home </a> |&nbsp;</li>
        <li><a href="http://networkx.github.com/documentation.html">Documentation </a>|&nbsp;</li>
        <li><a href="http://networkx.github.com/download.html">Download </a> |&nbsp;</li>
        <li><a href="http://github.com/networkx">Developer (Github)</a></li>



          <li><a href="index.html" >Reference</a> &raquo;</li>
          <li><a href="pdf_reference.html" >Reference</a> &raquo;</li>
          <li><a href="classes.html" accesskey="U">Graph types</a> &raquo;</li> 
      </ul>
    </div>



      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">MultiGraph - Undirected graphs with self loops and parallel edges</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#adding-and-removing-nodes-and-edges">Adding and removing nodes and edges</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#iterating-over-nodes-and-edges">Iterating over nodes and edges</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#information-about-graph-structure">Information about graph structure</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#making-copies-and-subgraphs">Making copies and subgraphs</a><ul>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="generated/networkx.DiGraph.reverse.html"
                        title="previous chapter">reverse</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="generated/networkx.MultiGraph.__init__.html"
                        title="next chapter">__init__</a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="multigraph-undirected-graphs-with-self-loops-and-parallel-edges">
<span id="multigraph"></span><h1>MultiGraph - Undirected graphs with self loops and parallel edges<a class="headerlink" href="#multigraph-undirected-graphs-with-self-loops-and-parallel-edges" title="Permalink to this headline">¶</a></h1>
<div class="section" id="overview">
<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="networkx.MultiGraph">
<tt class="descname">MultiGraph</tt><big>(</big><em>data=None</em>, <em>**attr</em><big>)</big><a class="headerlink" href="#networkx.MultiGraph" title="Permalink to this definition">¶</a></dt>
<dd><p>An undirected graph class that can store multiedges.</p>
<p>Multiedges are multiple edges between two nodes.  Each edge
can hold optional data or attributes.</p>
<p>A MultiGraph holds undirected edges.  Self loops are allowed.</p>
<p>Nodes can be arbitrary (hashable) Python objects with optional
key/value attributes.</p>
<p>Edges are represented as links between nodes with optional
key/value attributes.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters :</th><td class="field-body"><p class="first"><strong>data</strong> : input graph</p>
<blockquote>
<div><p>Data to initialize graph.  If data=None (default) an empty
graph is created.  The data can be an edge list, or any
NetworkX graph object.  If the corresponding optional Python
packages are installed the data can also be a NumPy matrix
or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph.</p>
</div></blockquote>
<p><strong>attr</strong> : keyword arguments, optional (default= no attributes)</p>
<blockquote class="last">
<div><p>Attributes to add to graph as key=value pairs.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="classes.graph.html#networkx.Graph" title="networkx.Graph"><tt class="xref py py-obj docutils literal"><span class="pre">Graph</span></tt></a>, <a class="reference internal" href="classes.digraph.html#networkx.DiGraph" title="networkx.DiGraph"><tt class="xref py py-obj docutils literal"><span class="pre">DiGraph</span></tt></a>, <a class="reference internal" href="classes.multidigraph.html#networkx.MultiDiGraph" title="networkx.MultiDiGraph"><tt class="xref py py-obj docutils literal"><span class="pre">MultiDiGraph</span></tt></a></p>
</div>
<p class="rubric">Examples</p>
<p>Create an empty graph structure (a &#8220;null graph&#8221;) with no nodes and
no edges.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">MultiGraph</span><span class="p">()</span>
</pre></div>
</div>
<p>G can be grown in several ways.</p>
<p><strong>Nodes:</strong></p>
<p>Add one node at a time:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_node</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Add the nodes from any container (a list, dict, set or
even the lines from a file or the nodes from another graph).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_nodes_from</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_nodes_from</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">H</span><span class="o">=</span><span class="n">nx</span><span class="o">.</span><span class="n">Graph</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">H</span><span class="o">.</span><span class="n">add_path</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">,</span><span class="mi">9</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_nodes_from</span><span class="p">(</span><span class="n">H</span><span class="p">)</span>
</pre></div>
</div>
<p>In addition to strings and integers any hashable Python object
(except None) can represent a node, e.g. a customized node object,
or even another Graph.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_node</span><span class="p">(</span><span class="n">H</span><span class="p">)</span>
</pre></div>
</div>
<p><strong>Edges:</strong></p>
<p>G can also be grown by adding edges.</p>
<p>Add one edge,</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>a list of edges,</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edges_from</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">),(</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">)])</span>
</pre></div>
</div>
<p>or a collection of edges,</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edges_from</span><span class="p">(</span><span class="n">H</span><span class="o">.</span><span class="n">edges</span><span class="p">())</span>
</pre></div>
</div>
<p>If some edges connect nodes not yet in the graph, the nodes
are added automatically.  If an edge already exists, an additional
edge is created and stored using a key to identify the edge.
By default the key is the lowest unused integer.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edges_from</span><span class="p">([(</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="nb">dict</span><span class="p">(</span><span class="n">route</span><span class="o">=</span><span class="mi">282</span><span class="p">)),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="nb">dict</span><span class="p">(</span><span class="n">route</span><span class="o">=</span><span class="mi">37</span><span class="p">))])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span>
<span class="go">{3: {0: {}}, 5: {0: {}, 1: {&#39;route&#39;: 282}, 2: {&#39;route&#39;: 37}}}</span>
</pre></div>
</div>
<p><strong>Attributes:</strong></p>
<p>Each graph, node, and edge can hold key/value attribute pairs
in an associated attribute dictionary (the keys must be hashable).
By default these are empty, but can be added or changed using
add_edge, add_node or direct manipulation of the attribute
dictionaries named graph, node and edge respectively.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">MultiGraph</span><span class="p">(</span><span class="n">day</span><span class="o">=</span><span class="s">&quot;Friday&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">graph</span>
<span class="go">{&#39;day&#39;: &#39;Friday&#39;}</span>
</pre></div>
</div>
<p>Add node attributes using add_node(), add_nodes_from() or G.node</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_node</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">time</span><span class="o">=</span><span class="s">&#39;5pm&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_nodes_from</span><span class="p">([</span><span class="mi">3</span><span class="p">],</span> <span class="n">time</span><span class="o">=</span><span class="s">&#39;2pm&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">node</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="go">{&#39;time&#39;: &#39;5pm&#39;}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">node</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;room&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">714</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">del</span> <span class="n">G</span><span class="o">.</span><span class="n">node</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;room&#39;</span><span class="p">]</span> <span class="c"># remove attribute</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">nodes</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">[(1, {&#39;time&#39;: &#39;5pm&#39;}), (3, {&#39;time&#39;: &#39;2pm&#39;})]</span>
</pre></div>
</div>
<p>Warning: adding a node to G.node does not add it to the graph.</p>
<p>Add edge attributes using add_edge(), add_edges_from(), subscript
notation, or G.edge.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">weight</span><span class="o">=</span><span class="mf">4.7</span> <span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edges_from</span><span class="p">([(</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">),(</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">)],</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;red&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">add_edges_from</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,{</span><span class="s">&#39;color&#39;</span><span class="p">:</span><span class="s">&#39;blue&#39;</span><span class="p">}),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,{</span><span class="s">&#39;weight&#39;</span><span class="p">:</span><span class="mi">8</span><span class="p">})])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">2</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s">&#39;weight&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">4.7</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">edge</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">2</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s">&#39;weight&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">4</span>
</pre></div>
</div>
<p><strong>Shortcuts:</strong></p>
<p>Many common graph features allow python syntax to speed reporting.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span> <span class="ow">in</span> <span class="n">G</span>     <span class="c"># check if node in graph</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">n</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">G</span> <span class="k">if</span> <span class="n">n</span><span class="o">&lt;</span><span class="mi">3</span><span class="p">]</span>   <span class="c"># iterate through nodes</span>
<span class="go">[1, 2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">G</span><span class="p">)</span>  <span class="c"># number of nodes in graph</span>
<span class="go">5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="c"># adjacency dict keyed by neighbor to edge attributes</span>
<span class="gp">... </span>           <span class="c"># Note: you should not change this dict manually!</span>
<span class="go">{2: {0: {&#39;weight&#39;: 4}, 1: {&#39;color&#39;: &#39;blue&#39;}}}</span>
</pre></div>
</div>
<p>The fastest way to traverse all edges of a graph is via
adjacency_iter(), but the edges() method is often more convenient.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">n</span><span class="p">,</span><span class="n">nbrsdict</span> <span class="ow">in</span> <span class="n">G</span><span class="o">.</span><span class="n">adjacency_iter</span><span class="p">():</span>
<span class="gp">... </span>    <span class="k">for</span> <span class="n">nbr</span><span class="p">,</span><span class="n">keydict</span> <span class="ow">in</span> <span class="n">nbrsdict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="gp">... </span>       <span class="k">for</span> <span class="n">key</span><span class="p">,</span><span class="n">eattr</span> <span class="ow">in</span> <span class="n">keydict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="gp">... </span>           <span class="k">if</span> <span class="s">&#39;weight&#39;</span> <span class="ow">in</span> <span class="n">eattr</span><span class="p">:</span>
<span class="gp">... </span>               <span class="p">(</span><span class="n">n</span><span class="p">,</span><span class="n">nbr</span><span class="p">,</span><span class="n">eattr</span><span class="p">[</span><span class="s">&#39;weight&#39;</span><span class="p">])</span>
<span class="go">(1, 2, 4)</span>
<span class="go">(2, 1, 4)</span>
<span class="go">(2, 3, 8)</span>
<span class="go">(3, 2, 8)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span><span class="n">v</span><span class="p">,</span><span class="n">edata</span><span class="p">[</span><span class="s">&#39;weight&#39;</span><span class="p">])</span> <span class="k">for</span> <span class="n">u</span><span class="p">,</span><span class="n">v</span><span class="p">,</span><span class="n">edata</span> <span class="ow">in</span> <span class="n">G</span><span class="o">.</span><span class="n">edges</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="k">if</span> <span class="s">&#39;weight&#39;</span> <span class="ow">in</span> <span class="n">edata</span> <span class="p">]</span>
<span class="go">[(1, 2, 4), (2, 3, 8)]</span>
</pre></div>
</div>
<p><strong>Reporting:</strong></p>
<p>Simple graph information is obtained using methods.
Iterator versions of many reporting methods exist for efficiency.
Methods exist for reporting nodes(), edges(), neighbors() and degree()
as well as the number of nodes and edges.</p>
<p>For details on these and other miscellaneous methods, see below.</p>
</dd></dl>

</div>
<div class="section" id="adding-and-removing-nodes-and-edges">
<h2>Adding and removing nodes and edges<a class="headerlink" href="#adding-and-removing-nodes-and-edges" title="Permalink to this headline">¶</a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.__init__.html#networkx.MultiGraph.__init__" title="networkx.MultiGraph.__init__"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.__init__</span></tt></a>([data])</td>
<td>Initialize a graph with edges, name, graph attributes.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_node.html#networkx.MultiGraph.add_node" title="networkx.MultiGraph.add_node"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_node</span></tt></a>(n[,&nbsp;attr_dict])</td>
<td>Add a single node n and update node attributes.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_nodes_from.html#networkx.MultiGraph.add_nodes_from" title="networkx.MultiGraph.add_nodes_from"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_nodes_from</span></tt></a>(nodes,&nbsp;**attr)</td>
<td>Add multiple nodes.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.remove_node.html#networkx.MultiGraph.remove_node" title="networkx.MultiGraph.remove_node"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.remove_node</span></tt></a>(n)</td>
<td>Remove node n.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.remove_nodes_from.html#networkx.MultiGraph.remove_nodes_from" title="networkx.MultiGraph.remove_nodes_from"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.remove_nodes_from</span></tt></a>(nodes)</td>
<td>Remove multiple nodes.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_edge.html#networkx.MultiGraph.add_edge" title="networkx.MultiGraph.add_edge"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_edge</span></tt></a>(u,&nbsp;v[,&nbsp;key,&nbsp;attr_dict])</td>
<td>Add an edge between u and v.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_edges_from.html#networkx.MultiGraph.add_edges_from" title="networkx.MultiGraph.add_edges_from"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_edges_from</span></tt></a>(ebunch[,&nbsp;attr_dict])</td>
<td>Add all the edges in ebunch.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_weighted_edges_from.html#networkx.MultiGraph.add_weighted_edges_from" title="networkx.MultiGraph.add_weighted_edges_from"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_weighted_edges_from</span></tt></a>(ebunch[,&nbsp;...])</td>
<td>Add all the edges in ebunch as weighted edges with specified weights.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.remove_edge.html#networkx.MultiGraph.remove_edge" title="networkx.MultiGraph.remove_edge"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.remove_edge</span></tt></a>(u,&nbsp;v[,&nbsp;key])</td>
<td>Remove an edge between u and v.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.remove_edges_from.html#networkx.MultiGraph.remove_edges_from" title="networkx.MultiGraph.remove_edges_from"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.remove_edges_from</span></tt></a>(ebunch)</td>
<td>Remove all edges specified in ebunch.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_star.html#networkx.MultiGraph.add_star" title="networkx.MultiGraph.add_star"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_star</span></tt></a>(nodes,&nbsp;**attr)</td>
<td>Add a star.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_path.html#networkx.MultiGraph.add_path" title="networkx.MultiGraph.add_path"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_path</span></tt></a>(nodes,&nbsp;**attr)</td>
<td>Add a path.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.add_cycle.html#networkx.MultiGraph.add_cycle" title="networkx.MultiGraph.add_cycle"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.add_cycle</span></tt></a>(nodes,&nbsp;**attr)</td>
<td>Add a cycle.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.clear.html#networkx.MultiGraph.clear" title="networkx.MultiGraph.clear"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.clear</span></tt></a>()</td>
<td>Remove all nodes and edges from the graph.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="iterating-over-nodes-and-edges">
<h2>Iterating over nodes and edges<a class="headerlink" href="#iterating-over-nodes-and-edges" title="Permalink to this headline">¶</a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.nodes.html#networkx.MultiGraph.nodes" title="networkx.MultiGraph.nodes"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.nodes</span></tt></a>([data])</td>
<td>Return a list of the nodes in the graph.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.nodes_iter.html#networkx.MultiGraph.nodes_iter" title="networkx.MultiGraph.nodes_iter"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.nodes_iter</span></tt></a>([data])</td>
<td>Return an iterator over the nodes.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.__iter__.html#networkx.MultiGraph.__iter__" title="networkx.MultiGraph.__iter__"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.__iter__</span></tt></a>()</td>
<td>Iterate over the nodes.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.edges.html#networkx.MultiGraph.edges" title="networkx.MultiGraph.edges"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.edges</span></tt></a>([nbunch,&nbsp;data,&nbsp;keys])</td>
<td>Return a list of edges.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.edges_iter.html#networkx.MultiGraph.edges_iter" title="networkx.MultiGraph.edges_iter"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.edges_iter</span></tt></a>([nbunch,&nbsp;data,&nbsp;keys])</td>
<td>Return an iterator over the edges.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.get_edge_data.html#networkx.MultiGraph.get_edge_data" title="networkx.MultiGraph.get_edge_data"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.get_edge_data</span></tt></a>(u,&nbsp;v[,&nbsp;key,&nbsp;default])</td>
<td>Return the attribute dictionary associated with edge (u,v).</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.neighbors.html#networkx.MultiGraph.neighbors" title="networkx.MultiGraph.neighbors"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.neighbors</span></tt></a>(n)</td>
<td>Return a list of the nodes connected to the node n.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.neighbors_iter.html#networkx.MultiGraph.neighbors_iter" title="networkx.MultiGraph.neighbors_iter"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.neighbors_iter</span></tt></a>(n)</td>
<td>Return an iterator over all neighbors of node n.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.__getitem__.html#networkx.MultiGraph.__getitem__" title="networkx.MultiGraph.__getitem__"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.__getitem__</span></tt></a>(n)</td>
<td>Return a dict of neighbors of node n.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.adjacency_list.html#networkx.MultiGraph.adjacency_list" title="networkx.MultiGraph.adjacency_list"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.adjacency_list</span></tt></a>()</td>
<td>Return an adjacency list representation of the graph.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.adjacency_iter.html#networkx.MultiGraph.adjacency_iter" title="networkx.MultiGraph.adjacency_iter"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.adjacency_iter</span></tt></a>()</td>
<td>Return an iterator of (node, adjacency dict) tuples for all nodes.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.nbunch_iter.html#networkx.MultiGraph.nbunch_iter" title="networkx.MultiGraph.nbunch_iter"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.nbunch_iter</span></tt></a>([nbunch])</td>
<td>Return an iterator of nodes contained in nbunch that are also in the graph.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="information-about-graph-structure">
<h2>Information about graph structure<a class="headerlink" href="#information-about-graph-structure" title="Permalink to this headline">¶</a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.has_node.html#networkx.MultiGraph.has_node" title="networkx.MultiGraph.has_node"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.has_node</span></tt></a>(n)</td>
<td>Return True if the graph contains the node n.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.__contains__.html#networkx.MultiGraph.__contains__" title="networkx.MultiGraph.__contains__"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.__contains__</span></tt></a>(n)</td>
<td>Return True if n is a node, False otherwise. Use the expression</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.has_edge.html#networkx.MultiGraph.has_edge" title="networkx.MultiGraph.has_edge"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.has_edge</span></tt></a>(u,&nbsp;v[,&nbsp;key])</td>
<td>Return True if the graph has an edge between nodes u and v.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.order.html#networkx.MultiGraph.order" title="networkx.MultiGraph.order"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.order</span></tt></a>()</td>
<td>Return the number of nodes in the graph.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.number_of_nodes.html#networkx.MultiGraph.number_of_nodes" title="networkx.MultiGraph.number_of_nodes"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.number_of_nodes</span></tt></a>()</td>
<td>Return the number of nodes in the graph.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.__len__.html#networkx.MultiGraph.__len__" title="networkx.MultiGraph.__len__"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.__len__</span></tt></a>()</td>
<td>Return the number of nodes.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.degree.html#networkx.MultiGraph.degree" title="networkx.MultiGraph.degree"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.degree</span></tt></a>([nbunch,&nbsp;weight])</td>
<td>Return the degree of a node or nodes.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.degree_iter.html#networkx.MultiGraph.degree_iter" title="networkx.MultiGraph.degree_iter"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.degree_iter</span></tt></a>([nbunch,&nbsp;weight])</td>
<td>Return an iterator for (node, degree).</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.size.html#networkx.MultiGraph.size" title="networkx.MultiGraph.size"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.size</span></tt></a>([weight])</td>
<td>Return the number of edges.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.number_of_edges.html#networkx.MultiGraph.number_of_edges" title="networkx.MultiGraph.number_of_edges"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.number_of_edges</span></tt></a>([u,&nbsp;v])</td>
<td>Return the number of edges between two nodes.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.nodes_with_selfloops.html#networkx.MultiGraph.nodes_with_selfloops" title="networkx.MultiGraph.nodes_with_selfloops"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.nodes_with_selfloops</span></tt></a>()</td>
<td>Return a list of nodes with self loops.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.selfloop_edges.html#networkx.MultiGraph.selfloop_edges" title="networkx.MultiGraph.selfloop_edges"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.selfloop_edges</span></tt></a>([data,&nbsp;keys])</td>
<td>Return a list of selfloop edges.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.number_of_selfloops.html#networkx.MultiGraph.number_of_selfloops" title="networkx.MultiGraph.number_of_selfloops"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.number_of_selfloops</span></tt></a>()</td>
<td>Return the number of selfloop edges.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="making-copies-and-subgraphs">
<h2>Making copies and subgraphs<a class="headerlink" href="#making-copies-and-subgraphs" title="Permalink to this headline">¶</a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.copy.html#networkx.MultiGraph.copy" title="networkx.MultiGraph.copy"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.copy</span></tt></a>()</td>
<td>Return a copy of the graph.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.to_undirected.html#networkx.MultiGraph.to_undirected" title="networkx.MultiGraph.to_undirected"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.to_undirected</span></tt></a>()</td>
<td>Return an undirected copy of the graph.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="generated/networkx.MultiGraph.to_directed.html#networkx.MultiGraph.to_directed" title="networkx.MultiGraph.to_directed"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.to_directed</span></tt></a>()</td>
<td>Return a directed representation of the graph.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="generated/networkx.MultiGraph.subgraph.html#networkx.MultiGraph.subgraph" title="networkx.MultiGraph.subgraph"><tt class="xref py py-obj docutils literal"><span class="pre">MultiGraph.subgraph</span></tt></a>(nbunch)</td>
<td>Return the subgraph induced on nodes in nbunch.</td>
</tr>
</tbody>
</table>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="generated/networkx.MultiGraph.__init__.html" title="__init__"
             >next</a> |</li>
        <li class="right" >
          <a href="generated/networkx.DiGraph.reverse.html" title="reverse"
             >previous</a> |</li>
        <li><a href="http://networkx.github.com/">NetworkX Home </a> |&nbsp;</li>
        <li><a href="http://networkx.github.com/documentation.html">Documentation </a>|&nbsp;</li>
        <li><a href="http://networkx.github.com/download.html">Download </a> |&nbsp;</li>
        <li><a href="http://github.com/networkx">Developer (Github)</a></li>



          <li><a href="index.html" >Reference</a> &raquo;</li>
          <li><a href="pdf_reference.html" >Reference</a> &raquo;</li>
          <li><a href="classes.html" >Graph types</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2013, NetworkX Developers.
      Last updated on Oct 23, 2013.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>