OpenCores
URL https://opencores.org/ocsvn/nocmodel/nocmodel/trunk

Subversion Repositories nocmodel

[/] [nocmodel/] [trunk/] [doc/] [nocmodel.noc_base.html] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dargor
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3
<html><head><title>Python: module nocmodel.noc_base</title>
4
</head><body bgcolor="#f0f0f8">
5
 
6
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
7
<tr bgcolor="#7799ee">
8
<td valign=bottom>&nbsp;<br>
9
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.noc_base</strong></big></big></font></td
10
><td align=right valign=bottom
11
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_base.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_base.py</a></font></td></tr></table>
12
    <p><tt>================<br>
13
NoCmodel&nbsp;Base&nbsp;Objects<br>
14
================<br>
15
&nbsp;&nbsp;<br>
16
This&nbsp;module&nbsp;declares&nbsp;classes&nbsp;used&nbsp;on&nbsp;a&nbsp;Network-on-chip&nbsp;representation:<br>
17
&nbsp;&nbsp;<br>
18
*&nbsp;NoC&nbsp;container&nbsp;class<br>
19
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Router&nbsp;base&nbsp;class<br>
20
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Channel&nbsp;base&nbsp;class<br>
21
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;IPCore&nbsp;base&nbsp;class<br>
22
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Protocol&nbsp;base&nbsp;class<br>
23
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Packet&nbsp;class</tt></p>
24
<p>
25
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
26
<tr bgcolor="#aa55cc">
27
<td colspan=3 valign=bottom>&nbsp;<br>
28
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
29
 
30
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
31
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="networkx.html">networkx</a><br>
32
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
33
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
34
<tr bgcolor="#ee77aa">
35
<td colspan=3 valign=bottom>&nbsp;<br>
36
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
37
 
38
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
39
<td width="100%"><dl>
40
<dt><font face="helvetica, arial"><a href="__builtin__.html#dict">__builtin__.dict</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
41
</font></dt><dd>
42
<dl>
43
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#packet">packet</a>
44
</font></dt></dl>
45
</dd>
46
<dt><font face="helvetica, arial"><a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
47
</font></dt><dd>
48
<dl>
49
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#noc">noc</a>
50
</font></dt></dl>
51
</dd>
52
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#nocobject">nocobject</a>
53
</font></dt><dd>
54
<dl>
55
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#channel">channel</a>
56
</font></dt><dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#ipcore">ipcore</a>
57
</font></dt><dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#protocol">protocol</a>
58
</font></dt><dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#router">router</a>
59
</font></dt></dl>
60
</dd>
61
</dl>
62
 <p>
63
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
64
<tr bgcolor="#ffc8d8">
65
<td colspan=3 valign=bottom>&nbsp;<br>
66
<font color="#000000" face="helvetica, arial"><a name="channel">class <strong>channel</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
67
 
68
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
69
<td colspan=2><tt>Channel&nbsp;base&nbsp;object<br>
70
&nbsp;<br>
71
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;and&nbsp;its&nbsp;properties.&nbsp;This&nbsp;base&nbsp;class<br>
72
is&nbsp;meant&nbsp;to&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;other&nbsp;attributes.<br>
73
&nbsp;<br>
74
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
75
*&nbsp;It&nbsp;should&nbsp;be&nbsp;related&nbsp;to&nbsp;one&nbsp;NoC&nbsp;model&nbsp;object&nbsp;(self.<strong>graph_ref</strong>)<br>
76
*&nbsp;It&nbsp;may&nbsp;be&nbsp;one&nbsp;of&nbsp;the&nbsp;edge&nbsp;attributes&nbsp;in&nbsp;the&nbsp;graph&nbsp;model&nbsp;<br>
77
&nbsp;&nbsp;(edge["channel_ref"]).&nbsp;In&nbsp;this&nbsp;case,&nbsp;this&nbsp;<a href="#channel">channel</a>&nbsp;connects&nbsp;two&nbsp;routers<br>
78
&nbsp;&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model.<br>
79
*&nbsp;It&nbsp;should&nbsp;have&nbsp;two&nbsp;references&nbsp;to&nbsp;NoC&nbsp;objects&nbsp;(self.<strong>endpoints</strong>).&nbsp;Two&nbsp;options<br>
80
&nbsp;&nbsp;exists:&nbsp;two&nbsp;routers&nbsp;references&nbsp;(<a href="#channel">channel</a>&nbsp;has&nbsp;an&nbsp;edge&nbsp;object)&nbsp;or,&nbsp;one<br>
81
&nbsp;&nbsp;<a href="#router">router</a>&nbsp;and&nbsp;one&nbsp;<a href="#ipcore">ipcore</a>&nbsp;(<a href="#channel">channel</a>&nbsp;don't&nbsp;have&nbsp;any&nbsp;edge&nbsp;object).<br>
82
&nbsp;<br>
83
Attributes:<br>
84
*&nbsp;name<br>
85
*&nbsp;index:&nbsp;optional&nbsp;index&nbsp;on&nbsp;a&nbsp;<a href="#noc">noc</a>&nbsp;object.&nbsp;Must&nbsp;have&nbsp;an&nbsp;index&nbsp;when&nbsp;it&nbsp;has<br>
86
&nbsp;&nbsp;a&nbsp;related&nbsp;edge&nbsp;in&nbsp;the&nbsp;graph&nbsp;model&nbsp;(and&nbsp;allowing&nbsp;it&nbsp;to&nbsp;be&nbsp;able&nbsp;to&nbsp;do<br>
87
&nbsp;&nbsp;<a href="#channel">channel</a>&nbsp;searching).&nbsp;None&nbsp;means&nbsp;it&nbsp;is&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;related&nbsp;<a href="#channel">channel</a><br>
88
*&nbsp;graph_ref&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;graph&nbsp;model<br>
89
*&nbsp;endpoints&nbsp;optional&nbsp;two-item&nbsp;list&nbsp;with&nbsp;references&nbsp;to&nbsp;the&nbsp;connected&nbsp;objects<br>&nbsp;</tt></td></tr>
90
<tr><td>&nbsp;</td>
91
<td width="100%">Methods defined here:<br>
92
<dl><dt><a name="channel-__init__"><strong>__init__</strong></a>(self, name, index<font color="#909090">=None</font>, **kwargs)</dt></dl>
93
 
94
<dl><dt><a name="channel-is_ipcore_link"><strong>is_ipcore_link</strong></a>(self)</dt><dd><tt>Checks&nbsp;if&nbsp;this&nbsp;<a href="#channel">channel</a>&nbsp;is&nbsp;a&nbsp;special&nbsp;link&nbsp;for&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>.<br>
95
&nbsp;<br>
96
Return:&nbsp;True&nbsp;if&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;is&nbsp;related&nbsp;to&nbsp;an&nbsp;<a href="#ipcore">ipcore</a></tt></dd></dl>
97
 
98
<hr>
99
Methods inherited from <a href="nocmodel.noc_base.html#nocobject">nocobject</a>:<br>
100
<dl><dt><a name="channel-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
101
 
102
</td></tr></table> <p>
103
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
104
<tr bgcolor="#ffc8d8">
105
<td colspan=3 valign=bottom>&nbsp;<br>
106
<font color="#000000" face="helvetica, arial"><a name="ipcore">class <strong>ipcore</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
107
 
108
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
109
<td colspan=2><tt>IP&nbsp;core&nbsp;base&nbsp;object<br>
110
&nbsp;<br>
111
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;IP&nbsp;Core&nbsp;object&nbsp;and&nbsp;its&nbsp;properties.&nbsp;This&nbsp;base&nbsp;class<br>
112
is&nbsp;meant&nbsp;to&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;other&nbsp;attributes.<br>
113
&nbsp;<br>
114
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
115
*&nbsp;It&nbsp;should&nbsp;be&nbsp;related&nbsp;to&nbsp;one&nbsp;NoC&nbsp;model&nbsp;object&nbsp;(self.<strong>graph_ref</strong>)<br>
116
*&nbsp;It&nbsp;should&nbsp;have&nbsp;one&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;(self.<strong>router_ref</strong>),&nbsp;even&nbsp;if<br>
117
&nbsp;&nbsp;the&nbsp;<a href="#ipcore">ipcore</a>&nbsp;has&nbsp;a&nbsp;direct&nbsp;connection&nbsp;to&nbsp;the&nbsp;NoC.<br>
118
*&nbsp;It&nbsp;should&nbsp;have&nbsp;one&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;(self.<strong>channel_ref</strong>).&nbsp;This<br>
119
&nbsp;&nbsp;<a href="#channel">channel</a>&nbsp;exclusively&nbsp;link&nbsp;this&nbsp;<a href="#ipcore">ipcore</a>&nbsp;and&nbsp;its&nbsp;<a href="#router">router</a>.<br>
120
&nbsp;<br>
121
Attributes:<br>
122
*&nbsp;name<br>
123
*&nbsp;router_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;related&nbsp;<a href="#router">router</a>.<br>
124
*&nbsp;channel_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;related&nbsp;<a href="#channel">channel</a><br>
125
*&nbsp;graph_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;graph&nbsp;model<br>&nbsp;</tt></td></tr>
126
<tr><td>&nbsp;</td>
127
<td width="100%">Methods defined here:<br>
128
<dl><dt><a name="ipcore-__init__"><strong>__init__</strong></a>(self, name, **kwargs)</dt></dl>
129
 
130
<hr>
131
Methods inherited from <a href="nocmodel.noc_base.html#nocobject">nocobject</a>:<br>
132
<dl><dt><a name="ipcore-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
133
 
134
</td></tr></table> <p>
135
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
136
<tr bgcolor="#ffc8d8">
137
<td colspan=3 valign=bottom>&nbsp;<br>
138
<font color="#000000" face="helvetica, arial"><a name="noc">class <strong>noc</strong></a>(<a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>)</font></td></tr>
139
 
140
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
141
<td colspan=2><tt>Base&nbsp;class&nbsp;for&nbsp;NoC&nbsp;modeling.<br>
142
Based&nbsp;on&nbsp;a&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a>&nbsp;object&nbsp;that&nbsp;hold&nbsp;the&nbsp;NoC&nbsp;structure<br>
143
&nbsp;<br>
144
Arguments<br>
145
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>&nbsp;</tt></td></tr>
146
<tr><td>&nbsp;</td>
147
<td width="100%"><dl><dt>Method resolution order:</dt>
148
<dd><a href="nocmodel.noc_base.html#noc">noc</a></dd>
149
<dd><a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a></dd>
150
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
151
</dl>
152
<hr>
153
Methods defined here:<br>
154
<dl><dt><a name="noc-__init__"><strong>__init__</strong></a>(self, **kwargs)</dt><dd><tt>NoCmodel&nbsp;constructor</tt></dd></dl>
155
 
156
<dl><dt><a name="noc-add_channel"><strong>add_channel</strong></a>(self, router1, router2, name<font color="#909090">=''</font>, **kwargs)</dt><dd><tt>Create&nbsp;a&nbsp;base&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;to&nbsp;link&nbsp;two&nbsp;objects&nbsp;and&nbsp;add&nbsp;it&nbsp;<br>
157
to&nbsp;NoC&nbsp;model.<br>
158
&nbsp;<br>
159
Arguments:<br>
160
*&nbsp;router1:&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#router">router</a>,&nbsp;<a href="#router">router</a>&nbsp;index&nbsp;or&nbsp;<a href="#ipcore">ipcore</a><br>
161
*&nbsp;router2:&nbsp;-idem-<br>
162
*&nbsp;name:&nbsp;optional&nbsp;argument&nbsp;for&nbsp;<a href="#channel">channel</a>&nbsp;name<br>
163
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>
164
&nbsp;<br>
165
Notes:<br>
166
*&nbsp;If&nbsp;router1&nbsp;or&nbsp;router2&nbsp;is&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;reference,&nbsp;this&nbsp;method&nbsp;creates<br>
167
&nbsp;&nbsp;the&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;and&nbsp;update&nbsp;<a href="#ipcore">ipcore</a>&nbsp;references.&nbsp;Additionally,<br>
168
&nbsp;&nbsp;if&nbsp;both&nbsp;arguments&nbsp;are&nbsp;ipcores,&nbsp;throw&nbsp;an&nbsp;error&nbsp;exception</tt></dd></dl>
169
 
170
<dl><dt><a name="noc-add_from_channel"><strong>add_from_channel</strong></a>(self, channel_ref, router1<font color="#909090">=None</font>, router2<font color="#909090">=None</font>)</dt><dd><tt>Add&nbsp;a&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;to&nbsp;NoC&nbsp;model.<br>
171
&nbsp;<br>
172
Use&nbsp;this&nbsp;function&nbsp;to&nbsp;add&nbsp;an&nbsp;object&nbsp;based&nbsp;on&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;<br>
173
base&nbsp;<a href="#channel">channel</a>&nbsp;defined&nbsp;in&nbsp;this&nbsp;module.<br>
174
&nbsp;<br>
175
Arguments<br>
176
*&nbsp;channel_ref:&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;object<br>
177
*&nbsp;router1:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#router">router</a>,&nbsp;<a href="#router">router</a>&nbsp;index&nbsp;or&nbsp;<a href="#ipcore">ipcore</a><br>
178
*&nbsp;router2:&nbsp;-idem-<br>
179
&nbsp;<br>
180
Return:&nbsp;the&nbsp;same&nbsp;reference&nbsp;passed&nbsp;in&nbsp;channel_ref<br>
181
&nbsp;<br>
182
Notes:<br>
183
*&nbsp;If&nbsp;router1&nbsp;or&nbsp;router2&nbsp;are&nbsp;not&nbsp;used&nbsp;as&nbsp;arguments,&nbsp;will&nbsp;assume&nbsp;that<br>
184
&nbsp;&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;has&nbsp;defined&nbsp;its&nbsp;attribute&nbsp;"endpoints"&nbsp;with&nbsp;the&nbsp;<br>
185
&nbsp;&nbsp;objects&nbsp;to&nbsp;connect.&nbsp;If&nbsp;the&nbsp;objects&nbsp;don't&nbsp;exist&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model,<br>
186
&nbsp;&nbsp;throw&nbsp;an&nbsp;error&nbsp;exception.<br>
187
&nbsp;<br>
188
*&nbsp;If&nbsp;router1&nbsp;or&nbsp;router2&nbsp;is&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;reference,&nbsp;this&nbsp;method&nbsp;creates<br>
189
&nbsp;&nbsp;the&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;and&nbsp;update&nbsp;<a href="#ipcore">ipcore</a>&nbsp;references.&nbsp;Additionally,<br>
190
&nbsp;&nbsp;if&nbsp;both&nbsp;arguments&nbsp;are&nbsp;ipcores,&nbsp;throw&nbsp;an&nbsp;error&nbsp;exception.<br>
191
&nbsp;&nbsp;&nbsp;&nbsp;<br>
192
*&nbsp;This&nbsp;function&nbsp;will&nbsp;change&nbsp;channel_ref.index&nbsp;and&nbsp;channel_ref.graph_ref&nbsp;<br>
193
&nbsp;&nbsp;attributes&nbsp;when&nbsp;inserted&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model.&nbsp;Also&nbsp;it&nbsp;may&nbsp;change&nbsp;<br>
194
&nbsp;&nbsp;channel_ref.endpoints&nbsp;with&nbsp;router1&nbsp;and&nbsp;router2&nbsp;references.</tt></dd></dl>
195
 
196
<dl><dt><a name="noc-add_from_ipcore"><strong>add_from_ipcore</strong></a>(self, ipcore_ref, router_ref, channel_ref<font color="#909090">=None</font>)</dt><dd><tt>Add&nbsp;a&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;to&nbsp;NoC&nbsp;model.<br>
197
&nbsp;<br>
198
Arguments<br>
199
*&nbsp;ipcore_ref:&nbsp;reference&nbsp;to&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object<br>
200
*&nbsp;router_ref:&nbsp;reference&nbsp;to&nbsp;an&nbsp;existing&nbsp;<a href="#router">router</a>&nbsp;to&nbsp;connect<br>
201
*&nbsp;channel_ref:&nbsp;optional&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;that&nbsp;connect&nbsp;the&nbsp;<a href="#router">router</a>&nbsp;and<br>
202
&nbsp;&nbsp;the&nbsp;<a href="#ipcore">ipcore</a>.&nbsp;If&nbsp;not&nbsp;used,&nbsp;this&nbsp;function&nbsp;will&nbsp;create&nbsp;a&nbsp;new&nbsp;<a href="#channel">channel</a>&nbsp;object.<br>
203
&nbsp;<br>
204
Return:&nbsp;the&nbsp;same&nbsp;reference&nbsp;passed&nbsp;in&nbsp;ipcore_ref<br>
205
&nbsp;<br>
206
Notes:<br>
207
*&nbsp;This&nbsp;function&nbsp;automatically&nbsp;adds&nbsp;a&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;<br>
208
&nbsp;&nbsp;(<a href="#router">router</a>-to-<a href="#ipcore">ipcore</a>)&nbsp;and&nbsp;adjust&nbsp;its&nbsp;relations&nbsp;in&nbsp;all&nbsp;involved&nbsp;objects.</tt></dd></dl>
209
 
210
<dl><dt><a name="noc-add_ipcore"><strong>add_ipcore</strong></a>(self, router_ref, name<font color="#909090">=''</font>, **kwargs)</dt><dd><tt>Create&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;and&nbsp;connect&nbsp;it&nbsp;to&nbsp;the&nbsp;<a href="#router">router</a>&nbsp;reference&nbsp;argument<br>
211
&nbsp;<br>
212
Arguments<br>
213
*&nbsp;router_ref:&nbsp;reference&nbsp;to&nbsp;an&nbsp;existing&nbsp;<a href="#router">router</a><br>
214
*&nbsp;name:&nbsp;optional&nbsp;name&nbsp;for&nbsp;this&nbsp;<a href="#router">router</a>.&nbsp;By&nbsp;default&nbsp;has&nbsp;the&nbsp;form&nbsp;of&nbsp;<br>
215
&nbsp;&nbsp;"IP_&lt;router_index&gt;"<br>
216
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>
217
&nbsp;<br>
218
Return:&nbsp;reference&nbsp;to&nbsp;the&nbsp;created&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object<br>
219
&nbsp;<br>
220
Notes:<br>
221
*&nbsp;This&nbsp;function&nbsp;automatically&nbsp;adds&nbsp;a&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;<br>
222
&nbsp;&nbsp;(<a href="#router">router</a>-to-<a href="#ipcore">ipcore</a>)&nbsp;and&nbsp;adjust&nbsp;its&nbsp;relations&nbsp;in&nbsp;all&nbsp;involved&nbsp;objects.</tt></dd></dl>
223
 
224
<dl><dt><a name="noc-add_router"><strong>add_router</strong></a>(self, name<font color="#909090">=''</font>, with_ipcore<font color="#909090">=False</font>, **kwargs)</dt><dd><tt>Create&nbsp;a&nbsp;base&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;and&nbsp;add&nbsp;it&nbsp;to&nbsp;NoC&nbsp;model.<br>
225
&nbsp;<br>
226
Arguments<br>
227
*&nbsp;name:&nbsp;optional&nbsp;name&nbsp;for&nbsp;this&nbsp;<a href="#router">router</a>.&nbsp;By&nbsp;default&nbsp;has&nbsp;the&nbsp;form&nbsp;of&nbsp;<br>
228
&nbsp;&nbsp;"R_&lt;index&gt;"<br>
229
*&nbsp;with_ipcore:&nbsp;If&nbsp;True,&nbsp;add&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;to&nbsp;the&nbsp;created&nbsp;<a href="#router">router</a>.<br>
230
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>
231
&nbsp;<br>
232
Return:&nbsp;reference&nbsp;to&nbsp;the&nbsp;created&nbsp;<a href="#router">router</a>&nbsp;object</tt></dd></dl>
233
 
234
<dl><dt><a name="noc-add_router_from_object"><strong>add_router_from_object</strong></a>(self, router_ref)</dt><dd><tt>Add&nbsp;an&nbsp;existing&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;to&nbsp;NoC&nbsp;model.<br>
235
&nbsp;<br>
236
Use&nbsp;this&nbsp;function&nbsp;to&nbsp;add&nbsp;an&nbsp;object&nbsp;based&nbsp;on&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;<br>
237
base&nbsp;<a href="#router">router</a>&nbsp;defined&nbsp;in&nbsp;this&nbsp;module.<br>
238
&nbsp;<br>
239
Arguments<br>
240
*&nbsp;router_ref:&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#router">router</a>&nbsp;object<br>
241
&nbsp;<br>
242
Return:&nbsp;the&nbsp;same&nbsp;reference&nbsp;passed&nbsp;in&nbsp;router_ref<br>
243
&nbsp;<br>
244
Notes:&nbsp;<br>
245
*&nbsp;This&nbsp;function&nbsp;will&nbsp;change&nbsp;router_ref.index&nbsp;and&nbsp;router_ref.graph_ref&nbsp;<br>
246
&nbsp;&nbsp;attributes&nbsp;when&nbsp;inserted&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model.</tt></dd></dl>
247
 
248
<dl><dt><a name="noc-all_list"><strong>all_list</strong></a>(self)</dt></dl>
249
 
250
<dl><dt><a name="noc-channel_list"><strong>channel_list</strong></a>(self)</dt></dl>
251
 
252
<dl><dt><a name="noc-del_channel"><strong>del_channel</strong></a>(self, channel_ref)</dt><dd><tt>Remove&nbsp;channel_ref&nbsp;from&nbsp;the&nbsp;NoC&nbsp;model<br>
253
&nbsp;<br>
254
TODO:&nbsp;not&nbsp;implemented</tt></dd></dl>
255
 
256
<dl><dt><a name="noc-del_ipcore"><strong>del_ipcore</strong></a>(self, ipcore_ref)</dt><dd><tt>Remove&nbsp;ipcore_ref&nbsp;from&nbsp;the&nbsp;NoC&nbsp;model<br>
257
&nbsp;<br>
258
TODO:&nbsp;not&nbsp;implemented</tt></dd></dl>
259
 
260
<dl><dt><a name="noc-del_router"><strong>del_router</strong></a>(self, router_ref)</dt><dd><tt>Remove&nbsp;router_ref&nbsp;from&nbsp;the&nbsp;NoC&nbsp;model<br>
261
&nbsp;<br>
262
TODO:&nbsp;not&nbsp;implemented</tt></dd></dl>
263
 
264
<dl><dt><a name="noc-get_router_by_address"><strong>get_router_by_address</strong></a>(self, address)</dt><dd><tt>#&nbsp;query&nbsp;functions</tt></dd></dl>
265
 
266
<dl><dt><a name="noc-ipcore_list"><strong>ipcore_list</strong></a>(self)</dt></dl>
267
 
268
<dl><dt><a name="noc-router_list"><strong>router_list</strong></a>(self)</dt><dd><tt>#&nbsp;list&nbsp;generation&nbsp;functions</tt></dd></dl>
269
 
270
<hr>
271
Methods inherited from <a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>:<br>
272
<dl><dt><a name="noc-__contains__"><strong>__contains__</strong></a>(self, n)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;n&nbsp;is&nbsp;a&nbsp;node,&nbsp;False&nbsp;otherwise.&nbsp;Use&nbsp;the&nbsp;expression<br>
273
'n&nbsp;in&nbsp;G'.<br>
274
&nbsp;<br>
275
Examples<br>
276
--------<br>
277
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
278
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
279
&gt;&gt;&gt;&nbsp;print&nbsp;1&nbsp;in&nbsp;G<br>
280
True</tt></dd></dl>
281
 
282
<dl><dt><a name="noc-__getitem__"><strong>__getitem__</strong></a>(self, n)</dt><dd><tt>Return&nbsp;a&nbsp;<a href="__builtin__.html#dict">dict</a>&nbsp;of&nbsp;neighbors&nbsp;of&nbsp;node&nbsp;n.&nbsp;&nbsp;Use&nbsp;the&nbsp;expression&nbsp;'G[n]'.<br>
283
&nbsp;<br>
284
Parameters<br>
285
----------<br>
286
n&nbsp;:&nbsp;node<br>
287
&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;in&nbsp;the&nbsp;graph.<br>
288
&nbsp;<br>
289
Returns<br>
290
-------<br>
291
adj_dict&nbsp;:&nbsp;dictionary<br>
292
&nbsp;&nbsp;&nbsp;The&nbsp;adjacency&nbsp;dictionary&nbsp;for&nbsp;nodes&nbsp;connected&nbsp;to&nbsp;n.<br>
293
&nbsp;<br>
294
Notes<br>
295
-----<br>
296
G[n]&nbsp;is&nbsp;similar&nbsp;to&nbsp;G.<a href="#noc-neighbors">neighbors</a>(n)&nbsp;but&nbsp;the&nbsp;internal&nbsp;data&nbsp;dictionary<br>
297
is&nbsp;returned&nbsp;instead&nbsp;of&nbsp;a&nbsp;list.<br>
298
&nbsp;<br>
299
Assigning&nbsp;G[n]&nbsp;will&nbsp;corrupt&nbsp;the&nbsp;internal&nbsp;graph&nbsp;data&nbsp;structure.<br>
300
Use&nbsp;G[n]&nbsp;for&nbsp;reading&nbsp;data&nbsp;only.<br>
301
&nbsp;<br>
302
Examples<br>
303
--------<br>
304
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
305
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
306
&gt;&gt;&gt;&nbsp;print&nbsp;G[0]<br>
307
{1:&nbsp;{}}</tt></dd></dl>
308
 
309
<dl><dt><a name="noc-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>Iterate&nbsp;over&nbsp;the&nbsp;nodes.&nbsp;Use&nbsp;the&nbsp;expression&nbsp;'for&nbsp;n&nbsp;in&nbsp;G'.<br>
310
&nbsp;<br>
311
Returns<br>
312
-------<br>
313
niter&nbsp;:&nbsp;iterator<br>
314
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;over&nbsp;all&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
315
&nbsp;<br>
316
Examples<br>
317
--------<br>
318
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
319
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
320
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G:<br>
321
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n,<br>
322
0&nbsp;1&nbsp;2&nbsp;3</tt></dd></dl>
323
 
324
<dl><dt><a name="noc-__len__"><strong>__len__</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;nodes.&nbsp;Use&nbsp;the&nbsp;expression&nbsp;'len(G)'.<br>
325
&nbsp;<br>
326
Returns<br>
327
-------<br>
328
nnodes&nbsp;:&nbsp;int<br>
329
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
330
&nbsp;<br>
331
Examples<br>
332
--------<br>
333
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
334
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
335
&gt;&gt;&gt;&nbsp;print&nbsp;len(G)<br>
336
4</tt></dd></dl>
337
 
338
<dl><dt><a name="noc-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;graph&nbsp;name.<br>
339
&nbsp;<br>
340
Returns<br>
341
-------<br>
342
name&nbsp;:&nbsp;string<br>
343
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;name&nbsp;of&nbsp;the&nbsp;graph.<br>
344
&nbsp;<br>
345
Examples<br>
346
--------<br>
347
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.path_graph(4)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
348
&gt;&gt;&gt;&nbsp;print&nbsp;G<br>
349
path_graph(4)</tt></dd></dl>
350
 
351
<dl><dt><a name="noc-add_cycle"><strong>add_cycle</strong></a>(self, nlist, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;cycle.<br>
352
&nbsp;<br>
353
Parameters<br>
354
----------<br>
355
nlist&nbsp;:&nbsp;list&nbsp;<br>
356
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;A&nbsp;cycle&nbsp;will&nbsp;be&nbsp;constructed&nbsp;from<br>
357
&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;nodes&nbsp;(in&nbsp;order)&nbsp;and&nbsp;added&nbsp;to&nbsp;the&nbsp;graph.<br>
358
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
359
&nbsp;&nbsp;&nbsp;&nbsp;Attributes&nbsp;to&nbsp;add&nbsp;to&nbsp;every&nbsp;edge&nbsp;in&nbsp;cycle.<br>
360
&nbsp;<br>
361
See&nbsp;Also<br>
362
--------<br>
363
add_path,&nbsp;add_star<br>
364
&nbsp;<br>
365
Examples<br>
366
--------<br>
367
&gt;&gt;&gt;&nbsp;G=nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
368
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_cycle">add_cycle</a>([0,1,2,3])<br>
369
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_cycle">add_cycle</a>([10,11,12],weight=7)</tt></dd></dl>
370
 
371
<dl><dt><a name="noc-add_edge"><strong>add_edge</strong></a>(self, u, v, attr_dict<font color="#909090">=None</font>, **attr)</dt><dd><tt>Add&nbsp;an&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
372
&nbsp;<br>
373
The&nbsp;nodes&nbsp;u&nbsp;and&nbsp;v&nbsp;will&nbsp;be&nbsp;automatically&nbsp;added&nbsp;if&nbsp;they&nbsp;are&nbsp;<br>
374
not&nbsp;already&nbsp;in&nbsp;the&nbsp;graph.&nbsp;&nbsp;<br>
375
&nbsp;<br>
376
Edge&nbsp;attributes&nbsp;can&nbsp;be&nbsp;specified&nbsp;with&nbsp;keywords&nbsp;or&nbsp;by&nbsp;providing<br>
377
a&nbsp;dictionary&nbsp;with&nbsp;key/value&nbsp;pairs.&nbsp;&nbsp;See&nbsp;examples&nbsp;below.<br>
378
&nbsp;<br>
379
Parameters<br>
380
----------<br>
381
u,v&nbsp;:&nbsp;nodes<br>
382
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;can&nbsp;be,&nbsp;for&nbsp;example,&nbsp;strings&nbsp;or&nbsp;numbers.&nbsp;<br>
383
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;must&nbsp;be&nbsp;hashable&nbsp;(and&nbsp;not&nbsp;None)&nbsp;Python&nbsp;objects.<br>
384
attr_dict&nbsp;:&nbsp;dictionary,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
385
&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;of&nbsp;edge&nbsp;attributes.&nbsp;&nbsp;Key/value&nbsp;pairs&nbsp;will<br>
386
&nbsp;&nbsp;&nbsp;&nbsp;update&nbsp;existing&nbsp;data&nbsp;associated&nbsp;with&nbsp;the&nbsp;edge.<br>
387
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional<br>
388
&nbsp;&nbsp;&nbsp;&nbsp;Edge&nbsp;data&nbsp;(or&nbsp;labels&nbsp;or&nbsp;objects)&nbsp;can&nbsp;be&nbsp;assigned&nbsp;using<br>
389
&nbsp;&nbsp;&nbsp;&nbsp;keyword&nbsp;arguments.&nbsp;&nbsp;&nbsp;<br>
390
&nbsp;<br>
391
See&nbsp;Also<br>
392
--------<br>
393
add_edges_from&nbsp;:&nbsp;add&nbsp;a&nbsp;collection&nbsp;of&nbsp;edges<br>
394
&nbsp;<br>
395
Notes&nbsp;<br>
396
-----<br>
397
Adding&nbsp;an&nbsp;edge&nbsp;that&nbsp;already&nbsp;exists&nbsp;updates&nbsp;the&nbsp;edge&nbsp;data.<br>
398
&nbsp;<br>
399
NetworkX&nbsp;algorithms&nbsp;designed&nbsp;for&nbsp;weighted&nbsp;graphs&nbsp;use&nbsp;as<br>
400
the&nbsp;edge&nbsp;weight&nbsp;a&nbsp;numerical&nbsp;value&nbsp;assigned&nbsp;to&nbsp;the&nbsp;keyword<br>
401
'weight'.<br>
402
&nbsp;<br>
403
Examples<br>
404
--------<br>
405
The&nbsp;following&nbsp;all&nbsp;add&nbsp;the&nbsp;edge&nbsp;e=(1,2)&nbsp;to&nbsp;graph&nbsp;G:<br>
406
&nbsp;<br>
407
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
408
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(1,2)<br>
409
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,&nbsp;2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;explicit&nbsp;two-node&nbsp;form<br>
410
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(*e)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;single&nbsp;edge&nbsp;as&nbsp;tuple&nbsp;of&nbsp;two&nbsp;nodes<br>
411
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>(&nbsp;[(1,2)]&nbsp;)&nbsp;#&nbsp;add&nbsp;edges&nbsp;from&nbsp;iterable&nbsp;container<br>
412
&nbsp;<br>
413
Associate&nbsp;data&nbsp;to&nbsp;edges&nbsp;using&nbsp;keywords:<br>
414
&nbsp;<br>
415
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,&nbsp;2,&nbsp;weight=3)<br>
416
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,&nbsp;3,&nbsp;weight=7,&nbsp;capacity=15,&nbsp;length=342.7)</tt></dd></dl>
417
 
418
<dl><dt><a name="noc-add_edges_from"><strong>add_edges_from</strong></a>(self, ebunch, attr_dict<font color="#909090">=None</font>, **attr)</dt><dd><tt>Add&nbsp;all&nbsp;the&nbsp;edges&nbsp;in&nbsp;ebunch.<br>
419
&nbsp;<br>
420
Parameters<br>
421
----------<br>
422
ebunch&nbsp;:&nbsp;container&nbsp;of&nbsp;edges<br>
423
&nbsp;&nbsp;&nbsp;&nbsp;Each&nbsp;edge&nbsp;given&nbsp;in&nbsp;the&nbsp;container&nbsp;will&nbsp;be&nbsp;added&nbsp;to&nbsp;the<br>
424
&nbsp;&nbsp;&nbsp;&nbsp;graph.&nbsp;The&nbsp;edges&nbsp;must&nbsp;be&nbsp;given&nbsp;as&nbsp;as&nbsp;2-tuples&nbsp;(u,v)&nbsp;or<br>
425
&nbsp;&nbsp;&nbsp;&nbsp;3-tuples&nbsp;(u,v,d)&nbsp;where&nbsp;d&nbsp;is&nbsp;a&nbsp;dictionary&nbsp;containing&nbsp;edge<br>
426
&nbsp;&nbsp;&nbsp;&nbsp;data.<br>
427
attr_dict&nbsp;:&nbsp;dictionary,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
428
&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;of&nbsp;edge&nbsp;attributes.&nbsp;&nbsp;Key/value&nbsp;pairs&nbsp;will<br>
429
&nbsp;&nbsp;&nbsp;&nbsp;update&nbsp;existing&nbsp;data&nbsp;associated&nbsp;with&nbsp;each&nbsp;edge.<br>
430
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional<br>
431
&nbsp;&nbsp;&nbsp;&nbsp;Edge&nbsp;data&nbsp;(or&nbsp;labels&nbsp;or&nbsp;objects)&nbsp;can&nbsp;be&nbsp;assigned&nbsp;using<br>
432
&nbsp;&nbsp;&nbsp;&nbsp;keyword&nbsp;arguments.&nbsp;&nbsp;&nbsp;<br>
433
&nbsp;<br>
434
&nbsp;<br>
435
See&nbsp;Also<br>
436
--------<br>
437
add_edge&nbsp;:&nbsp;add&nbsp;a&nbsp;single&nbsp;edge<br>
438
add_weighted_edges_from&nbsp;:&nbsp;convenient&nbsp;way&nbsp;to&nbsp;add&nbsp;weighted&nbsp;edges<br>
439
&nbsp;<br>
440
Notes<br>
441
-----<br>
442
Adding&nbsp;the&nbsp;same&nbsp;edge&nbsp;twice&nbsp;has&nbsp;no&nbsp;effect&nbsp;but&nbsp;any&nbsp;edge&nbsp;data<br>
443
will&nbsp;be&nbsp;updated&nbsp;when&nbsp;each&nbsp;duplicate&nbsp;edge&nbsp;is&nbsp;added.<br>
444
&nbsp;<br>
445
Examples<br>
446
--------<br>
447
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
448
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>([(0,1),(1,2)])&nbsp;#&nbsp;using&nbsp;a&nbsp;list&nbsp;of&nbsp;edge&nbsp;tuples<br>
449
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;zip(range(0,3),range(1,4))<br>
450
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>(e)&nbsp;#&nbsp;Add&nbsp;the&nbsp;path&nbsp;graph&nbsp;0-1-2-3<br>
451
&nbsp;<br>
452
Associate&nbsp;data&nbsp;to&nbsp;edges<br>
453
&nbsp;<br>
454
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>([(1,2),(2,3)],&nbsp;weight=3)<br>
455
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>([(3,4),(1,4)],&nbsp;label='WN2898')</tt></dd></dl>
456
 
457
<dl><dt><a name="noc-add_node"><strong>add_node</strong></a>(self, n, attr_dict<font color="#909090">=None</font>, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;single&nbsp;node&nbsp;n&nbsp;and&nbsp;update&nbsp;node&nbsp;attributes.<br>
458
&nbsp;<br>
459
Parameters<br>
460
----------<br>
461
n&nbsp;:&nbsp;node<br>
462
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;can&nbsp;be&nbsp;any&nbsp;hashable&nbsp;Python&nbsp;object&nbsp;except&nbsp;None.<br>
463
attr_dict&nbsp;:&nbsp;dictionary,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
464
&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;of&nbsp;node&nbsp;attributes.&nbsp;&nbsp;Key/value&nbsp;pairs&nbsp;will<br>
465
&nbsp;&nbsp;&nbsp;&nbsp;update&nbsp;existing&nbsp;data&nbsp;associated&nbsp;with&nbsp;the&nbsp;node.<br>
466
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional<br>
467
&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;or&nbsp;change&nbsp;attributes&nbsp;using&nbsp;key=value.<br>
468
&nbsp;<br>
469
See&nbsp;Also<br>
470
--------<br>
471
add_nodes_from<br>
472
&nbsp;<br>
473
Examples<br>
474
--------<br>
475
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
476
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(1)<br>
477
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>('Hello')<br>
478
&gt;&gt;&gt;&nbsp;K3&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>([(0,1),(1,2),(2,0)])<br>
479
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(K3)<br>
480
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_nodes">number_of_nodes</a>()<br>
481
3<br>
482
&nbsp;<br>
483
Use&nbsp;keywords&nbsp;set/change&nbsp;node&nbsp;attributes:<br>
484
&nbsp;<br>
485
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(1,size=10)<br>
486
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(3,weight=0.4,UTM=('13S',382871,3972649))<br>
487
&nbsp;<br>
488
Notes<br>
489
-----<br>
490
A&nbsp;hashable&nbsp;object&nbsp;is&nbsp;one&nbsp;that&nbsp;can&nbsp;be&nbsp;used&nbsp;as&nbsp;a&nbsp;key&nbsp;in&nbsp;a&nbsp;Python<br>
491
dictionary.&nbsp;This&nbsp;includes&nbsp;strings,&nbsp;numbers,&nbsp;tuples&nbsp;of&nbsp;strings<br>
492
and&nbsp;numbers,&nbsp;etc.<br>
493
&nbsp;<br>
494
On&nbsp;many&nbsp;platforms&nbsp;hashable&nbsp;items&nbsp;also&nbsp;include&nbsp;mutables&nbsp;such&nbsp;as<br>
495
NetworkX&nbsp;Graphs,&nbsp;though&nbsp;one&nbsp;should&nbsp;be&nbsp;careful&nbsp;that&nbsp;the&nbsp;hash<br>
496
doesn't&nbsp;change&nbsp;on&nbsp;mutables.</tt></dd></dl>
497
 
498
<dl><dt><a name="noc-add_nodes_from"><strong>add_nodes_from</strong></a>(self, nodes, **attr)</dt><dd><tt>Add&nbsp;multiple&nbsp;nodes.<br>
499
&nbsp;<br>
500
Parameters<br>
501
----------<br>
502
nodes&nbsp;:&nbsp;iterable&nbsp;container<br>
503
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes&nbsp;(list,&nbsp;<a href="__builtin__.html#dict">dict</a>,&nbsp;set,&nbsp;etc.).&nbsp;&nbsp;<br>
504
&nbsp;&nbsp;&nbsp;&nbsp;OR<br>
505
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;(node,&nbsp;attribute&nbsp;<a href="__builtin__.html#dict">dict</a>)&nbsp;tuples.<br>
506
&nbsp;&nbsp;&nbsp;&nbsp;Node&nbsp;attributes&nbsp;are&nbsp;updated&nbsp;using&nbsp;the&nbsp;attribute&nbsp;<a href="__builtin__.html#dict">dict</a>.<br>
507
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
508
&nbsp;&nbsp;&nbsp;&nbsp;Update&nbsp;attributes&nbsp;for&nbsp;all&nbsp;nodes&nbsp;in&nbsp;nodes.<br>
509
&nbsp;&nbsp;&nbsp;&nbsp;Node&nbsp;attributes&nbsp;specified&nbsp;in&nbsp;nodes&nbsp;as&nbsp;a&nbsp;tuple<br>
510
&nbsp;&nbsp;&nbsp;&nbsp;take&nbsp;precedence&nbsp;over&nbsp;attributes&nbsp;specified&nbsp;generally.<br>
511
&nbsp;<br>
512
See&nbsp;Also<br>
513
--------<br>
514
add_node<br>
515
&nbsp;<br>
516
Examples<br>
517
--------<br>
518
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
519
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>('Hello')<br>
520
&gt;&gt;&gt;&nbsp;K3&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>([(0,1),(1,2),(2,0)])<br>
521
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>(K3)<br>
522
&gt;&gt;&gt;&nbsp;sorted(G.<a href="#noc-nodes">nodes</a>())<br>
523
[0,&nbsp;1,&nbsp;2,&nbsp;'H',&nbsp;'e',&nbsp;'l',&nbsp;'o']<br>
524
&nbsp;<br>
525
Use&nbsp;keywords&nbsp;to&nbsp;update&nbsp;specific&nbsp;node&nbsp;attributes&nbsp;for&nbsp;every&nbsp;node.<br>
526
&nbsp;<br>
527
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>([1,2],&nbsp;size=10)<br>
528
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>([3,4],&nbsp;weight=0.4)<br>
529
&nbsp;<br>
530
Use&nbsp;(node,&nbsp;attrdict)&nbsp;tuples&nbsp;to&nbsp;update&nbsp;attributes&nbsp;for&nbsp;specific<br>
531
nodes.<br>
532
&nbsp;<br>
533
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>([(1,<a href="__builtin__.html#dict">dict</a>(size=11)),&nbsp;(2,{'color':'blue'})])<br>
534
&gt;&gt;&gt;&nbsp;G.node[1]['size']<br>
535
11<br>
536
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()<br>
537
&gt;&gt;&gt;&nbsp;H.<a href="#noc-add_nodes_from">add_nodes_from</a>(G.<a href="#noc-nodes">nodes</a>(data=True))<br>
538
&gt;&gt;&gt;&nbsp;H.node[1]['size']<br>
539
11</tt></dd></dl>
540
 
541
<dl><dt><a name="noc-add_path"><strong>add_path</strong></a>(self, nlist, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;path.<br>
542
&nbsp;<br>
543
Parameters<br>
544
----------<br>
545
nlist&nbsp;:&nbsp;list&nbsp;<br>
546
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;A&nbsp;path&nbsp;will&nbsp;be&nbsp;constructed&nbsp;from<br>
547
&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;nodes&nbsp;(in&nbsp;order)&nbsp;and&nbsp;added&nbsp;to&nbsp;the&nbsp;graph.<br>
548
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
549
&nbsp;&nbsp;&nbsp;&nbsp;Attributes&nbsp;to&nbsp;add&nbsp;to&nbsp;every&nbsp;edge&nbsp;in&nbsp;path.<br>
550
&nbsp;<br>
551
See&nbsp;Also<br>
552
--------<br>
553
add_star,&nbsp;add_cycle<br>
554
&nbsp;<br>
555
Examples<br>
556
--------<br>
557
&gt;&gt;&gt;&nbsp;G=nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
558
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
559
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([10,11,12],weight=7)</tt></dd></dl>
560
 
561
<dl><dt><a name="noc-add_star"><strong>add_star</strong></a>(self, nlist, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;star.<br>
562
&nbsp;<br>
563
The&nbsp;first&nbsp;node&nbsp;in&nbsp;nlist&nbsp;is&nbsp;the&nbsp;middle&nbsp;of&nbsp;the&nbsp;star.&nbsp;&nbsp;It&nbsp;is&nbsp;connected&nbsp;<br>
564
to&nbsp;all&nbsp;other&nbsp;nodes&nbsp;in&nbsp;nlist.<br>
565
&nbsp;<br>
566
Parameters<br>
567
----------<br>
568
nlist&nbsp;:&nbsp;list&nbsp;<br>
569
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;<br>
570
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
571
&nbsp;&nbsp;&nbsp;&nbsp;Attributes&nbsp;to&nbsp;add&nbsp;to&nbsp;every&nbsp;edge&nbsp;in&nbsp;star.<br>
572
&nbsp;<br>
573
See&nbsp;Also<br>
574
--------<br>
575
add_path,&nbsp;add_cycle<br>
576
&nbsp;<br>
577
Examples<br>
578
--------<br>
579
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
580
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_star">add_star</a>([0,1,2,3])<br>
581
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_star">add_star</a>([10,11,12],weight=2)</tt></dd></dl>
582
 
583
<dl><dt><a name="noc-add_weighted_edges_from"><strong>add_weighted_edges_from</strong></a>(self, ebunch, **attr)</dt><dd><tt>Add&nbsp;all&nbsp;the&nbsp;edges&nbsp;in&nbsp;ebunch&nbsp;as&nbsp;weighted&nbsp;edges&nbsp;with&nbsp;specified<br>
584
weights.<br>
585
&nbsp;<br>
586
Parameters<br>
587
----------<br>
588
ebunch&nbsp;:&nbsp;container&nbsp;of&nbsp;edges<br>
589
&nbsp;&nbsp;&nbsp;&nbsp;Each&nbsp;edge&nbsp;given&nbsp;in&nbsp;the&nbsp;list&nbsp;or&nbsp;container&nbsp;will&nbsp;be&nbsp;added<br>
590
&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;the&nbsp;graph.&nbsp;The&nbsp;edges&nbsp;must&nbsp;be&nbsp;given&nbsp;as&nbsp;3-tuples&nbsp;(u,v,w)<br>
591
&nbsp;&nbsp;&nbsp;&nbsp;where&nbsp;w&nbsp;is&nbsp;a&nbsp;number.<br>
592
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
593
&nbsp;&nbsp;&nbsp;&nbsp;Edge&nbsp;attributes&nbsp;to&nbsp;add/update&nbsp;for&nbsp;all&nbsp;edges.<br>
594
&nbsp;<br>
595
See&nbsp;Also<br>
596
--------<br>
597
add_edge&nbsp;:&nbsp;add&nbsp;a&nbsp;single&nbsp;edge<br>
598
add_edges_from&nbsp;:&nbsp;add&nbsp;multiple&nbsp;edges<br>
599
&nbsp;<br>
600
Notes<br>
601
-----<br>
602
Adding&nbsp;the&nbsp;same&nbsp;edge&nbsp;twice&nbsp;has&nbsp;no&nbsp;effect&nbsp;but&nbsp;any&nbsp;edge&nbsp;data<br>
603
will&nbsp;be&nbsp;updated&nbsp;when&nbsp;each&nbsp;duplicate&nbsp;edge&nbsp;is&nbsp;added.<br>
604
&nbsp;<br>
605
Examples<br>
606
--------<br>
607
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
608
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_weighted_edges_from">add_weighted_edges_from</a>([(0,1,3.0),(1,2,7.5)])</tt></dd></dl>
609
 
610
<dl><dt><a name="noc-adjacency_iter"><strong>adjacency_iter</strong></a>(self)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;of&nbsp;(node,&nbsp;adjacency&nbsp;<a href="__builtin__.html#dict">dict</a>)&nbsp;tuples&nbsp;for&nbsp;all&nbsp;nodes.<br>
611
&nbsp;<br>
612
This&nbsp;is&nbsp;the&nbsp;fastest&nbsp;way&nbsp;to&nbsp;look&nbsp;at&nbsp;every&nbsp;edge.&nbsp;<br>
613
For&nbsp;directed&nbsp;graphs,&nbsp;only&nbsp;outgoing&nbsp;adjacencies&nbsp;are&nbsp;included.<br>
614
&nbsp;<br>
615
Returns<br>
616
-------<br>
617
adj_iter&nbsp;:&nbsp;iterator<br>
618
&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;of&nbsp;(node,&nbsp;adjacency&nbsp;dictionary)&nbsp;for&nbsp;all&nbsp;nodes&nbsp;in<br>
619
&nbsp;&nbsp;&nbsp;the&nbsp;graph.<br>
620
&nbsp;<br>
621
See&nbsp;Also<br>
622
--------<br>
623
adjacency_list<br>
624
&nbsp;&nbsp;&nbsp;<br>
625
Examples&nbsp;&nbsp;&nbsp;<br>
626
--------<br>
627
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
628
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
629
&gt;&gt;&gt;&nbsp;[(n,nbrdict)&nbsp;for&nbsp;n,nbrdict&nbsp;in&nbsp;G.<a href="#noc-adjacency_iter">adjacency_iter</a>()]<br>
630
[(0,&nbsp;{1:&nbsp;{}}),&nbsp;(1,&nbsp;{0:&nbsp;{},&nbsp;2:&nbsp;{}}),&nbsp;(2,&nbsp;{1:&nbsp;{},&nbsp;3:&nbsp;{}}),&nbsp;(3,&nbsp;{2:&nbsp;{}})]</tt></dd></dl>
631
 
632
<dl><dt><a name="noc-adjacency_list"><strong>adjacency_list</strong></a>(self)</dt><dd><tt>Return&nbsp;an&nbsp;adjacency&nbsp;list&nbsp;representation&nbsp;of&nbsp;the&nbsp;graph.<br>
633
&nbsp;<br>
634
The&nbsp;output&nbsp;adjacency&nbsp;list&nbsp;is&nbsp;in&nbsp;the&nbsp;order&nbsp;of&nbsp;G.<a href="#noc-nodes">nodes</a>().<br>
635
For&nbsp;directed&nbsp;graphs,&nbsp;only&nbsp;outgoing&nbsp;adjacencies&nbsp;are&nbsp;included.&nbsp;<br>
636
&nbsp;<br>
637
Returns<br>
638
-------<br>
639
adj_list&nbsp;:&nbsp;lists&nbsp;of&nbsp;lists<br>
640
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;adjacency&nbsp;structure&nbsp;of&nbsp;the&nbsp;graph&nbsp;as&nbsp;a&nbsp;list&nbsp;of&nbsp;lists.<br>
641
&nbsp;<br>
642
See&nbsp;Also<br>
643
--------<br>
644
adjacency_iter<br>
645
&nbsp;<br>
646
Examples<br>
647
--------<br>
648
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
649
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
650
&gt;&gt;&gt;&nbsp;G.<a href="#noc-adjacency_list">adjacency_list</a>()&nbsp;#&nbsp;in&nbsp;order&nbsp;given&nbsp;by&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
651
[[1],&nbsp;[0,&nbsp;2],&nbsp;[1,&nbsp;3],&nbsp;[2]]</tt></dd></dl>
652
 
653
<dl><dt><a name="noc-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Remove&nbsp;all&nbsp;nodes&nbsp;and&nbsp;edges&nbsp;from&nbsp;the&nbsp;graph.<br>
654
&nbsp;<br>
655
This&nbsp;also&nbsp;removes&nbsp;the&nbsp;name,&nbsp;and&nbsp;all&nbsp;graph,&nbsp;node,&nbsp;and&nbsp;edge&nbsp;attributes.<br>
656
&nbsp;<br>
657
Examples<br>
658
--------<br>
659
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
660
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
661
&gt;&gt;&gt;&nbsp;G.<a href="#noc-clear">clear</a>()<br>
662
&gt;&gt;&gt;&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
663
[]<br>
664
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
665
[]</tt></dd></dl>
666
 
667
<dl><dt><a name="noc-copy"><strong>copy</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.<br>
668
&nbsp;<br>
669
Returns<br>
670
-------<br>
671
G&nbsp;:&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a><br>
672
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.&nbsp;&nbsp;&nbsp;<br>
673
&nbsp;<br>
674
See&nbsp;Also<br>
675
--------<br>
676
to_directed:&nbsp;return&nbsp;a&nbsp;directed&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.<br>
677
&nbsp;<br>
678
Notes<br>
679
-----<br>
680
This&nbsp;makes&nbsp;a&nbsp;complete&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph&nbsp;including&nbsp;all&nbsp;of&nbsp;the&nbsp;<br>
681
node&nbsp;or&nbsp;edge&nbsp;attributes.&nbsp;<br>
682
&nbsp;<br>
683
Examples<br>
684
--------<br>
685
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
686
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
687
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-copy">copy</a>()</tt></dd></dl>
688
 
689
<dl><dt><a name="noc-degree"><strong>degree</strong></a>(self, nbunch<font color="#909090">=None</font>, weighted<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;the&nbsp;degree&nbsp;of&nbsp;a&nbsp;node&nbsp;or&nbsp;nodes.<br>
690
&nbsp;<br>
691
The&nbsp;node&nbsp;degree&nbsp;is&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;adjacent&nbsp;to&nbsp;that&nbsp;node.&nbsp;<br>
692
&nbsp;<br>
693
Parameters<br>
694
----------<br>
695
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=all&nbsp;nodes)<br>
696
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
697
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
698
weighted&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
699
&nbsp;&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;the&nbsp;sum&nbsp;of&nbsp;edge&nbsp;weights&nbsp;adjacent&nbsp;to&nbsp;the&nbsp;node.&nbsp;&nbsp;<br>
700
&nbsp;<br>
701
Returns<br>
702
-------<br>
703
nd&nbsp;:&nbsp;dictionary,&nbsp;or&nbsp;number<br>
704
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;dictionary&nbsp;with&nbsp;nodes&nbsp;as&nbsp;keys&nbsp;and&nbsp;degree&nbsp;as&nbsp;values&nbsp;or<br>
705
&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;number&nbsp;if&nbsp;a&nbsp;single&nbsp;node&nbsp;is&nbsp;specified.<br>
706
&nbsp;<br>
707
Examples<br>
708
--------<br>
709
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
710
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
711
&gt;&gt;&gt;&nbsp;G.<a href="#noc-degree">degree</a>(0)<br>
712
1<br>
713
&gt;&gt;&gt;&nbsp;G.<a href="#noc-degree">degree</a>([0,1])<br>
714
{0:&nbsp;1,&nbsp;1:&nbsp;2}<br>
715
&gt;&gt;&gt;&nbsp;G.<a href="#noc-degree">degree</a>([0,1]).values()<br>
716
[1,&nbsp;2]</tt></dd></dl>
717
 
718
<dl><dt><a name="noc-degree_iter"><strong>degree_iter</strong></a>(self, nbunch<font color="#909090">=None</font>, weighted<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;for&nbsp;(node,&nbsp;degree).&nbsp;<br>
719
&nbsp;<br>
720
The&nbsp;node&nbsp;degree&nbsp;is&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;adjacent&nbsp;to&nbsp;the&nbsp;node.&nbsp;<br>
721
&nbsp;<br>
722
Parameters<br>
723
----------<br>
724
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=all&nbsp;nodes)<br>
725
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
726
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
727
weighted&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
728
&nbsp;&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;the&nbsp;sum&nbsp;of&nbsp;edge&nbsp;weights&nbsp;adjacent&nbsp;to&nbsp;the&nbsp;node.&nbsp;&nbsp;<br>
729
&nbsp;<br>
730
Returns<br>
731
-------<br>
732
nd_iter&nbsp;:&nbsp;an&nbsp;iterator&nbsp;<br>
733
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;iterator&nbsp;returns&nbsp;two-tuples&nbsp;of&nbsp;(node,&nbsp;degree).<br>
734
&nbsp;<br>
735
See&nbsp;Also<br>
736
--------<br>
737
degree<br>
738
&nbsp;<br>
739
Examples<br>
740
--------<br>
741
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
742
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
743
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-degree_iter">degree_iter</a>(0))&nbsp;#&nbsp;node&nbsp;0&nbsp;with&nbsp;degree&nbsp;1<br>
744
[(0,&nbsp;1)]<br>
745
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-degree_iter">degree_iter</a>([0,1]))<br>
746
[(0,&nbsp;1),&nbsp;(1,&nbsp;2)]</tt></dd></dl>
747
 
748
<dl><dt><a name="noc-edges"><strong>edges</strong></a>(self, nbunch<font color="#909090">=None</font>, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;edges.<br>
749
&nbsp;<br>
750
Edges&nbsp;are&nbsp;returned&nbsp;as&nbsp;tuples&nbsp;with&nbsp;optional&nbsp;data&nbsp;<br>
751
in&nbsp;the&nbsp;order&nbsp;(node,&nbsp;neighbor,&nbsp;data).<br>
752
&nbsp;<br>
753
Parameters<br>
754
----------<br>
755
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=&nbsp;all&nbsp;nodes)<br>
756
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
757
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.<br>
758
data&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
759
&nbsp;&nbsp;&nbsp;&nbsp;Return&nbsp;two&nbsp;tuples&nbsp;(u,v)&nbsp;(False)&nbsp;or&nbsp;three-tuples&nbsp;(u,v,data)&nbsp;(True).<br>
760
&nbsp;<br>
761
Returns<br>
762
--------<br>
763
edge_list:&nbsp;list&nbsp;of&nbsp;edge&nbsp;tuples<br>
764
&nbsp;&nbsp;&nbsp;&nbsp;Edges&nbsp;that&nbsp;are&nbsp;adjacent&nbsp;to&nbsp;any&nbsp;node&nbsp;in&nbsp;nbunch,&nbsp;or&nbsp;a&nbsp;list<br>
765
&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;all&nbsp;edges&nbsp;if&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;specified.<br>
766
&nbsp;<br>
767
See&nbsp;Also<br>
768
--------<br>
769
edges_iter&nbsp;:&nbsp;return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;edges<br>
770
&nbsp;<br>
771
Notes<br>
772
-----<br>
773
Nodes&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;not&nbsp;in&nbsp;the&nbsp;graph&nbsp;will&nbsp;be&nbsp;(quietly)&nbsp;ignored.<br>
774
&nbsp;<br>
775
Examples<br>
776
--------<br>
777
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
778
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
779
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
780
[(0,&nbsp;1),&nbsp;(1,&nbsp;2),&nbsp;(2,&nbsp;3)]<br>
781
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>(data=True)&nbsp;#&nbsp;default&nbsp;edge&nbsp;data&nbsp;is&nbsp;{}&nbsp;(empty&nbsp;dictionary)<br>
782
[(0,&nbsp;1,&nbsp;{}),&nbsp;(1,&nbsp;2,&nbsp;{}),&nbsp;(2,&nbsp;3,&nbsp;{})]<br>
783
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>([0,3])<br>
784
[(0,&nbsp;1),&nbsp;(3,&nbsp;2)]<br>
785
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>(0)<br>
786
[(0,&nbsp;1)]</tt></dd></dl>
787
 
788
<dl><dt><a name="noc-edges_iter"><strong>edges_iter</strong></a>(self, nbunch<font color="#909090">=None</font>, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;edges.<br>
789
&nbsp;<br>
790
Edges&nbsp;are&nbsp;returned&nbsp;as&nbsp;tuples&nbsp;with&nbsp;optional&nbsp;data&nbsp;<br>
791
in&nbsp;the&nbsp;order&nbsp;(node,&nbsp;neighbor,&nbsp;data).<br>
792
&nbsp;<br>
793
Parameters<br>
794
----------<br>
795
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=&nbsp;all&nbsp;nodes)<br>
796
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
797
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.<br>
798
data&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
799
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;True,&nbsp;return&nbsp;edge&nbsp;attribute&nbsp;<a href="__builtin__.html#dict">dict</a>&nbsp;in&nbsp;3-tuple&nbsp;(u,v,data).<br>
800
&nbsp;<br>
801
Returns<br>
802
-------<br>
803
edge_iter&nbsp;:&nbsp;iterator<br>
804
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;of&nbsp;(u,v)&nbsp;or&nbsp;(u,v,d)&nbsp;tuples&nbsp;of&nbsp;edges.<br>
805
&nbsp;<br>
806
See&nbsp;Also<br>
807
--------<br>
808
edges&nbsp;:&nbsp;return&nbsp;a&nbsp;list&nbsp;of&nbsp;edges<br>
809
&nbsp;<br>
810
Notes<br>
811
-----<br>
812
Nodes&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;not&nbsp;in&nbsp;the&nbsp;graph&nbsp;will&nbsp;be&nbsp;(quietly)&nbsp;ignored.<br>
813
&nbsp;<br>
814
Examples<br>
815
--------<br>
816
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiGraph,&nbsp;etc<br>
817
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
818
&gt;&gt;&gt;&nbsp;[e&nbsp;for&nbsp;e&nbsp;in&nbsp;G.<a href="#noc-edges_iter">edges_iter</a>()]<br>
819
[(0,&nbsp;1),&nbsp;(1,&nbsp;2),&nbsp;(2,&nbsp;3)]<br>
820
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-edges_iter">edges_iter</a>(data=True))&nbsp;#&nbsp;default&nbsp;data&nbsp;is&nbsp;{}&nbsp;(empty&nbsp;<a href="__builtin__.html#dict">dict</a>)<br>
821
[(0,&nbsp;1,&nbsp;{}),&nbsp;(1,&nbsp;2,&nbsp;{}),&nbsp;(2,&nbsp;3,&nbsp;{})]<br>
822
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-edges_iter">edges_iter</a>([0,3]))<br>
823
[(0,&nbsp;1),&nbsp;(3,&nbsp;2)]<br>
824
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-edges_iter">edges_iter</a>(0))<br>
825
[(0,&nbsp;1)]</tt></dd></dl>
826
 
827
<dl><dt><a name="noc-get_edge_data"><strong>get_edge_data</strong></a>(self, u, v, default<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;the&nbsp;attribute&nbsp;dictionary&nbsp;associated&nbsp;with&nbsp;edge&nbsp;(u,v).<br>
828
&nbsp;<br>
829
Parameters<br>
830
----------<br>
831
u,v&nbsp;:&nbsp;nodes<br>
832
default:&nbsp;&nbsp;any&nbsp;Python&nbsp;object&nbsp;(default=None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
833
&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;to&nbsp;return&nbsp;if&nbsp;the&nbsp;edge&nbsp;(u,v)&nbsp;is&nbsp;not&nbsp;found.&nbsp;&nbsp;<br>
834
&nbsp;&nbsp;&nbsp;&nbsp;<br>
835
Returns<br>
836
-------<br>
837
edge_dict&nbsp;:&nbsp;dictionary<br>
838
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;edge&nbsp;attribute&nbsp;dictionary.<br>
839
&nbsp;<br>
840
Notes<br>
841
-----<br>
842
It&nbsp;is&nbsp;faster&nbsp;to&nbsp;use&nbsp;G[u][v].<br>
843
&nbsp;<br>
844
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
845
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
846
&gt;&gt;&gt;&nbsp;G[0][1]<br>
847
{}<br>
848
&nbsp;<br>
849
Warning:&nbsp;Assigning&nbsp;G[u][v]&nbsp;corrupts&nbsp;the&nbsp;graph&nbsp;data&nbsp;structure.<br>
850
But&nbsp;it&nbsp;is&nbsp;safe&nbsp;to&nbsp;assign&nbsp;attributes&nbsp;to&nbsp;that&nbsp;dictionary,<br>
851
&nbsp;<br>
852
&gt;&gt;&gt;&nbsp;G[0][1]['weight']&nbsp;=&nbsp;7<br>
853
&gt;&gt;&gt;&nbsp;G[0][1]['weight']<br>
854
7<br>
855
&gt;&gt;&gt;&nbsp;G[1][0]['weight']<br>
856
7<br>
857
&nbsp;<br>
858
Examples<br>
859
--------<br>
860
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
861
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
862
&gt;&gt;&gt;&nbsp;G.<a href="#noc-get_edge_data">get_edge_data</a>(0,1)&nbsp;#&nbsp;default&nbsp;edge&nbsp;data&nbsp;is&nbsp;{}<br>
863
{}<br>
864
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1)<br>
865
&gt;&gt;&gt;&nbsp;G.<a href="#noc-get_edge_data">get_edge_data</a>(*e)&nbsp;#&nbsp;tuple&nbsp;form<br>
866
{}<br>
867
&gt;&gt;&gt;&nbsp;G.<a href="#noc-get_edge_data">get_edge_data</a>('a','b',default=0)&nbsp;#&nbsp;edge&nbsp;not&nbsp;in&nbsp;graph,&nbsp;return&nbsp;0<br>
868
0</tt></dd></dl>
869
 
870
<dl><dt><a name="noc-has_edge"><strong>has_edge</strong></a>(self, u, v)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;the&nbsp;edge&nbsp;(u,v)&nbsp;is&nbsp;in&nbsp;the&nbsp;graph.<br>
871
&nbsp;<br>
872
Parameters<br>
873
----------<br>
874
u,v&nbsp;:&nbsp;nodes<br>
875
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;can&nbsp;be,&nbsp;for&nbsp;example,&nbsp;strings&nbsp;or&nbsp;numbers.&nbsp;<br>
876
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;must&nbsp;be&nbsp;hashable&nbsp;(and&nbsp;not&nbsp;None)&nbsp;Python&nbsp;objects.<br>
877
&nbsp;&nbsp;&nbsp;&nbsp;<br>
878
Returns<br>
879
-------<br>
880
edge_ind&nbsp;:&nbsp;bool<br>
881
&nbsp;&nbsp;&nbsp;&nbsp;True&nbsp;if&nbsp;edge&nbsp;is&nbsp;in&nbsp;the&nbsp;graph,&nbsp;False&nbsp;otherwise.<br>
882
&nbsp;<br>
883
Examples<br>
884
--------<br>
885
Can&nbsp;be&nbsp;called&nbsp;either&nbsp;using&nbsp;two&nbsp;nodes&nbsp;u,v&nbsp;or&nbsp;edge&nbsp;tuple&nbsp;(u,v)<br>
886
&nbsp;<br>
887
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
888
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
889
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(0,1)&nbsp;&nbsp;#&nbsp;using&nbsp;two&nbsp;nodes<br>
890
True<br>
891
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1)<br>
892
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(*e)&nbsp;&nbsp;#&nbsp;&nbsp;e&nbsp;is&nbsp;a&nbsp;2-tuple&nbsp;(u,v)<br>
893
True<br>
894
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1,{'weight':7})<br>
895
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(*e[:2])&nbsp;&nbsp;#&nbsp;e&nbsp;is&nbsp;a&nbsp;3-tuple&nbsp;(u,v,data_dictionary)<br>
896
True<br>
897
&nbsp;<br>
898
The&nbsp;following&nbsp;syntax&nbsp;are&nbsp;all&nbsp;equivalent:&nbsp;<br>
899
&nbsp;<br>
900
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(0,1)<br>
901
True<br>
902
&gt;&gt;&gt;&nbsp;1&nbsp;in&nbsp;G[0]&nbsp;&nbsp;#&nbsp;though&nbsp;this&nbsp;gives&nbsp;KeyError&nbsp;if&nbsp;0&nbsp;not&nbsp;in&nbsp;G<br>
903
True</tt></dd></dl>
904
 
905
<dl><dt><a name="noc-has_node"><strong>has_node</strong></a>(self, n)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;the&nbsp;graph&nbsp;contains&nbsp;the&nbsp;node&nbsp;n.<br>
906
&nbsp;<br>
907
Parameters<br>
908
----------<br>
909
n&nbsp;:&nbsp;node<br>
910
&nbsp;<br>
911
Examples<br>
912
--------<br>
913
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
914
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
915
&gt;&gt;&gt;&nbsp;print&nbsp;G.<a href="#noc-has_node">has_node</a>(0)<br>
916
True<br>
917
&nbsp;<br>
918
It&nbsp;is&nbsp;more&nbsp;readable&nbsp;and&nbsp;simpler&nbsp;to&nbsp;use<br>
919
&nbsp;<br>
920
&gt;&gt;&gt;&nbsp;0&nbsp;in&nbsp;G<br>
921
True</tt></dd></dl>
922
 
923
<dl><dt><a name="noc-is_directed"><strong>is_directed</strong></a>(self)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;graph&nbsp;is&nbsp;directed,&nbsp;False&nbsp;otherwise.</tt></dd></dl>
924
 
925
<dl><dt><a name="noc-is_multigraph"><strong>is_multigraph</strong></a>(self)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;graph&nbsp;is&nbsp;a&nbsp;multigraph,&nbsp;False&nbsp;otherwise.</tt></dd></dl>
926
 
927
<dl><dt><a name="noc-nbunch_iter"><strong>nbunch_iter</strong></a>(self, nbunch<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;of&nbsp;nodes&nbsp;contained&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;<br>
928
also&nbsp;in&nbsp;the&nbsp;graph.<br>
929
&nbsp;<br>
930
The&nbsp;nodes&nbsp;in&nbsp;nbunch&nbsp;are&nbsp;checked&nbsp;for&nbsp;membership&nbsp;in&nbsp;the&nbsp;graph<br>
931
and&nbsp;if&nbsp;not&nbsp;are&nbsp;silently&nbsp;ignored.<br>
932
&nbsp;<br>
933
Parameters<br>
934
----------<br>
935
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=all&nbsp;nodes)<br>
936
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
937
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
938
&nbsp;<br>
939
Returns<br>
940
-------<br>
941
niter&nbsp;:&nbsp;iterator<br>
942
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;over&nbsp;nodes&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;also&nbsp;in&nbsp;the&nbsp;graph.<br>
943
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;nbunch&nbsp;is&nbsp;None,&nbsp;iterate&nbsp;over&nbsp;all&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
944
&nbsp;<br>
945
Raises<br>
946
------<br>
947
NetworkXError<br>
948
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;a&nbsp;node&nbsp;or&nbsp;or&nbsp;sequence&nbsp;of&nbsp;nodes.<br>
949
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;a&nbsp;node&nbsp;in&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;hashable.<br>
950
&nbsp;<br>
951
See&nbsp;Also<br>
952
--------<br>
953
<a href="networkx.classes.graph.html#Graph">Graph</a>.__iter__<br>
954
&nbsp;<br>
955
Notes&nbsp;<br>
956
-----<br>
957
When&nbsp;nbunch&nbsp;is&nbsp;an&nbsp;iterator,&nbsp;the&nbsp;returned&nbsp;iterator&nbsp;yields&nbsp;values&nbsp;<br>
958
directly&nbsp;from&nbsp;nbunch,&nbsp;becoming&nbsp;exhausted&nbsp;when&nbsp;nbunch&nbsp;is&nbsp;exhausted.<br>
959
&nbsp;<br>
960
To&nbsp;test&nbsp;whether&nbsp;nbunch&nbsp;is&nbsp;a&nbsp;single&nbsp;node,&nbsp;one&nbsp;can&nbsp;use&nbsp;<br>
961
"if&nbsp;nbunch&nbsp;in&nbsp;self:",&nbsp;even&nbsp;after&nbsp;processing&nbsp;with&nbsp;this&nbsp;routine.<br>
962
&nbsp;<br>
963
If&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;a&nbsp;node&nbsp;or&nbsp;a&nbsp;(possibly&nbsp;empty)&nbsp;sequence/iterator<br>
964
or&nbsp;None,&nbsp;a&nbsp;NetworkXError&nbsp;is&nbsp;raised.&nbsp;&nbsp;Also,&nbsp;if&nbsp;any&nbsp;object&nbsp;in<br>
965
nbunch&nbsp;is&nbsp;not&nbsp;hashable,&nbsp;a&nbsp;NetworkXError&nbsp;is&nbsp;raised.</tt></dd></dl>
966
 
967
<dl><dt><a name="noc-neighbors"><strong>neighbors</strong></a>(self, n)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;nodes&nbsp;connected&nbsp;to&nbsp;the&nbsp;node&nbsp;n.<br>
968
&nbsp;<br>
969
Parameters<br>
970
----------<br>
971
n&nbsp;:&nbsp;node<br>
972
&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;in&nbsp;the&nbsp;graph<br>
973
&nbsp;<br>
974
Returns<br>
975
-------<br>
976
nlist&nbsp;:&nbsp;list<br>
977
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes&nbsp;that&nbsp;are&nbsp;adjacent&nbsp;to&nbsp;n.<br>
978
&nbsp;<br>
979
Raises<br>
980
------<br>
981
NetworkXError<br>
982
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;the&nbsp;node&nbsp;n&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph.&nbsp;&nbsp;<br>
983
&nbsp;<br>
984
Notes<br>
985
-----<br>
986
It&nbsp;is&nbsp;usually&nbsp;more&nbsp;convenient&nbsp;(and&nbsp;faster)&nbsp;to&nbsp;access&nbsp;the<br>
987
adjacency&nbsp;dictionary&nbsp;as&nbsp;G[n]:<br>
988
&nbsp;<br>
989
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
990
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>('a','b',weight=7)<br>
991
&gt;&gt;&gt;&nbsp;G['a']<br>
992
{'b':&nbsp;{'weight':&nbsp;7}}<br>
993
&nbsp;<br>
994
Examples<br>
995
--------<br>
996
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
997
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
998
&gt;&gt;&gt;&nbsp;G.<a href="#noc-neighbors">neighbors</a>(0)<br>
999
[1]</tt></dd></dl>
1000
 
1001
<dl><dt><a name="noc-neighbors_iter"><strong>neighbors_iter</strong></a>(self, n)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;all&nbsp;neighbors&nbsp;of&nbsp;node&nbsp;n.<br>
1002
&nbsp;<br>
1003
Examples<br>
1004
--------<br>
1005
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1006
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
1007
&gt;&gt;&gt;&nbsp;print&nbsp;[n&nbsp;for&nbsp;n&nbsp;in&nbsp;G.<a href="#noc-neighbors_iter">neighbors_iter</a>(0)]<br>
1008
[1]<br>
1009
&nbsp;<br>
1010
Notes<br>
1011
-----<br>
1012
It&nbsp;is&nbsp;faster&nbsp;to&nbsp;use&nbsp;the&nbsp;idiom&nbsp;"in&nbsp;G[0]",&nbsp;e.g.<br>
1013
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G[0]:<br>
1014
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n<br>
1015
1</tt></dd></dl>
1016
 
1017
<dl><dt><a name="noc-nodes"><strong>nodes</strong></a>(self, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
1018
&nbsp;<br>
1019
Parameters<br>
1020
----------<br>
1021
data&nbsp;:&nbsp;boolean,&nbsp;optional&nbsp;(default=False)&nbsp;<br>
1022
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;False&nbsp;return&nbsp;a&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;a<br>
1023
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;two-tuple&nbsp;of&nbsp;node&nbsp;and&nbsp;node&nbsp;data&nbsp;dictionary<br>
1024
&nbsp;<br>
1025
Returns<br>
1026
-------<br>
1027
nlist&nbsp;:&nbsp;list<br>
1028
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;If&nbsp;data=True&nbsp;a&nbsp;list&nbsp;of&nbsp;two-tuples&nbsp;containing<br>
1029
&nbsp;&nbsp;&nbsp;&nbsp;(node,&nbsp;node&nbsp;data&nbsp;dictionary).&nbsp;<br>
1030
&nbsp;<br>
1031
Examples<br>
1032
--------<br>
1033
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1034
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
1035
&gt;&gt;&gt;&nbsp;print&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
1036
[0,&nbsp;1,&nbsp;2]<br>
1037
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(1,&nbsp;time='5pm')<br>
1038
&gt;&gt;&gt;&nbsp;print&nbsp;G.<a href="#noc-nodes">nodes</a>(data=True)<br>
1039
[(0,&nbsp;{}),&nbsp;(1,&nbsp;{'time':&nbsp;'5pm'}),&nbsp;(2,&nbsp;{})]</tt></dd></dl>
1040
 
1041
<dl><dt><a name="noc-nodes_iter"><strong>nodes_iter</strong></a>(self, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;nodes.<br>
1042
&nbsp;<br>
1043
Parameters<br>
1044
----------<br>
1045
data&nbsp;:&nbsp;boolean,&nbsp;optional&nbsp;(default=False)<br>
1046
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;False&nbsp;the&nbsp;iterator&nbsp;returns&nbsp;nodes.&nbsp;&nbsp;If&nbsp;True<br>
1047
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;a&nbsp;two-tuple&nbsp;of&nbsp;node&nbsp;and&nbsp;node&nbsp;data&nbsp;dictionary<br>
1048
&nbsp;<br>
1049
Returns<br>
1050
-------<br>
1051
niter&nbsp;:&nbsp;iterator<br>
1052
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;over&nbsp;nodes.&nbsp;&nbsp;If&nbsp;data=True&nbsp;the&nbsp;iterator&nbsp;gives&nbsp;<br>
1053
&nbsp;&nbsp;&nbsp;&nbsp;two-tuples&nbsp;containing&nbsp;(node,&nbsp;node&nbsp;data,&nbsp;dictionary)&nbsp;<br>
1054
&nbsp;<br>
1055
Notes<br>
1056
-----<br>
1057
If&nbsp;the&nbsp;node&nbsp;data&nbsp;is&nbsp;not&nbsp;required&nbsp;it&nbsp;is&nbsp;simpler&nbsp;and&nbsp;equivalent&nbsp;<br>
1058
to&nbsp;use&nbsp;the&nbsp;expression&nbsp;'for&nbsp;n&nbsp;in&nbsp;G'.<br>
1059
&nbsp;<br>
1060
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1061
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
1062
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G:<br>
1063
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n,<br>
1064
0&nbsp;1&nbsp;2<br>
1065
&nbsp;<br>
1066
&nbsp;<br>
1067
Examples<br>
1068
--------<br>
1069
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1070
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
1071
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G.<a href="#noc-nodes_iter">nodes_iter</a>():<br>
1072
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n,<br>
1073
0&nbsp;1&nbsp;2<br>
1074
&gt;&gt;&gt;&nbsp;for&nbsp;n,d&nbsp;in&nbsp;G.<a href="#noc-nodes_iter">nodes_iter</a>(data=True):<br>
1075
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;d,<br>
1076
{}&nbsp;{}&nbsp;{}</tt></dd></dl>
1077
 
1078
<dl><dt><a name="noc-nodes_with_selfloops"><strong>nodes_with_selfloops</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;nodes&nbsp;with&nbsp;self&nbsp;loops.<br>
1079
&nbsp;<br>
1080
A&nbsp;node&nbsp;with&nbsp;a&nbsp;self&nbsp;loop&nbsp;has&nbsp;an&nbsp;edge&nbsp;with&nbsp;both&nbsp;ends&nbsp;adjacent<br>
1081
to&nbsp;that&nbsp;node.<br>
1082
&nbsp;<br>
1083
Returns<br>
1084
-------<br>
1085
nodelist&nbsp;:&nbsp;list<br>
1086
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes&nbsp;with&nbsp;self&nbsp;loops.<br>
1087
&nbsp;<br>
1088
See&nbsp;Also<br>
1089
--------<br>
1090
selfloop_edges,&nbsp;number_of_selfloops<br>
1091
&nbsp;<br>
1092
Examples<br>
1093
--------<br>
1094
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1095
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,1)<br>
1096
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,2)<br>
1097
&gt;&gt;&gt;&nbsp;G.<a href="#noc-nodes_with_selfloops">nodes_with_selfloops</a>()<br>
1098
[1]</tt></dd></dl>
1099
 
1100
<dl><dt><a name="noc-number_of_edges"><strong>number_of_edges</strong></a>(self, u<font color="#909090">=None</font>, v<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;between&nbsp;two&nbsp;nodes.<br>
1101
&nbsp;<br>
1102
Parameters<br>
1103
----------<br>
1104
u,v&nbsp;:&nbsp;nodes,&nbsp;optional&nbsp;(default=all&nbsp;edges)<br>
1105
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;u&nbsp;and&nbsp;v&nbsp;are&nbsp;specified,&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;between&nbsp;<br>
1106
&nbsp;&nbsp;&nbsp;&nbsp;u&nbsp;and&nbsp;v.&nbsp;Otherwise&nbsp;return&nbsp;the&nbsp;total&nbsp;number&nbsp;of&nbsp;all&nbsp;edges.<br>
1107
&nbsp;&nbsp;&nbsp;&nbsp;<br>
1108
Returns<br>
1109
-------<br>
1110
nedges&nbsp;:&nbsp;int<br>
1111
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;edges&nbsp;in&nbsp;the&nbsp;graph.&nbsp;&nbsp;If&nbsp;nodes&nbsp;u&nbsp;and&nbsp;v&nbsp;are&nbsp;specified<br>
1112
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;between&nbsp;those&nbsp;nodes.<br>
1113
&nbsp;<br>
1114
See&nbsp;Also<br>
1115
--------<br>
1116
size<br>
1117
&nbsp;&nbsp;&nbsp;&nbsp;<br>
1118
Examples<br>
1119
--------<br>
1120
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1121
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
1122
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_edges">number_of_edges</a>()<br>
1123
3<br>
1124
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_edges">number_of_edges</a>(0,1)&nbsp;<br>
1125
1<br>
1126
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1)<br>
1127
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_edges">number_of_edges</a>(*e)<br>
1128
1</tt></dd></dl>
1129
 
1130
<dl><dt><a name="noc-number_of_nodes"><strong>number_of_nodes</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
1131
&nbsp;<br>
1132
Returns<br>
1133
-------<br>
1134
nnodes&nbsp;:&nbsp;int<br>
1135
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
1136
&nbsp;<br>
1137
See&nbsp;Also<br>
1138
--------<br>
1139
order,&nbsp;__len__&nbsp;&nbsp;which&nbsp;are&nbsp;identical&nbsp;<br>
1140
&nbsp;<br>
1141
Examples<br>
1142
--------<br>
1143
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1144
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
1145
&gt;&gt;&gt;&nbsp;print&nbsp;len(G)<br>
1146
3</tt></dd></dl>
1147
 
1148
<dl><dt><a name="noc-number_of_selfloops"><strong>number_of_selfloops</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;selfloop&nbsp;edges.<br>
1149
&nbsp;<br>
1150
A&nbsp;selfloop&nbsp;edge&nbsp;has&nbsp;the&nbsp;same&nbsp;node&nbsp;at&nbsp;both&nbsp;ends.<br>
1151
&nbsp;<br>
1152
Returns<br>
1153
-------<br>
1154
nloops&nbsp;:&nbsp;int<br>
1155
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;selfloops.&nbsp;&nbsp;&nbsp;<br>
1156
&nbsp;<br>
1157
See&nbsp;Also<br>
1158
--------<br>
1159
selfloop_nodes,&nbsp;selfloop_edges<br>
1160
&nbsp;<br>
1161
Examples<br>
1162
--------<br>
1163
&gt;&gt;&gt;&nbsp;G=nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1164
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,1)<br>
1165
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,2)<br>
1166
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_selfloops">number_of_selfloops</a>()<br>
1167
1</tt></dd></dl>
1168
 
1169
<dl><dt><a name="noc-order"><strong>order</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
1170
&nbsp;<br>
1171
Returns<br>
1172
-------<br>
1173
nnodes&nbsp;:&nbsp;int<br>
1174
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
1175
&nbsp;<br>
1176
See&nbsp;Also<br>
1177
--------<br>
1178
number_of_nodes,&nbsp;__len__&nbsp;&nbsp;which&nbsp;are&nbsp;identical</tt></dd></dl>
1179
 
1180
<dl><dt><a name="noc-remove_edge"><strong>remove_edge</strong></a>(self, u, v)</dt><dd><tt>Remove&nbsp;the&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
1181
&nbsp;<br>
1182
Parameters<br>
1183
----------<br>
1184
u,v:&nbsp;nodes&nbsp;<br>
1185
&nbsp;&nbsp;&nbsp;&nbsp;Remove&nbsp;the&nbsp;edge&nbsp;between&nbsp;nodes&nbsp;u&nbsp;and&nbsp;v.<br>
1186
&nbsp;<br>
1187
Raises<br>
1188
------<br>
1189
NetworkXError<br>
1190
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;there&nbsp;is&nbsp;not&nbsp;an&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
1191
&nbsp;<br>
1192
See&nbsp;Also<br>
1193
--------<br>
1194
remove_edges_from&nbsp;:&nbsp;remove&nbsp;a&nbsp;collection&nbsp;of&nbsp;edges<br>
1195
&nbsp;<br>
1196
Examples<br>
1197
--------<br>
1198
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;etc<br>
1199
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
1200
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edge">remove_edge</a>(0,1)<br>
1201
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(1,2)<br>
1202
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edge">remove_edge</a>(*e)&nbsp;#&nbsp;unpacks&nbsp;e&nbsp;from&nbsp;an&nbsp;edge&nbsp;tuple<br>
1203
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(2,3,{'weight':7})&nbsp;#&nbsp;an&nbsp;edge&nbsp;with&nbsp;attribute&nbsp;data<br>
1204
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edge">remove_edge</a>(*e[:2])&nbsp;#&nbsp;select&nbsp;first&nbsp;part&nbsp;of&nbsp;edge&nbsp;tuple</tt></dd></dl>
1205
 
1206
<dl><dt><a name="noc-remove_edges_from"><strong>remove_edges_from</strong></a>(self, ebunch)</dt><dd><tt>Remove&nbsp;all&nbsp;edges&nbsp;specified&nbsp;in&nbsp;ebunch.<br>
1207
&nbsp;<br>
1208
Parameters<br>
1209
----------<br>
1210
ebunch:&nbsp;list&nbsp;or&nbsp;container&nbsp;of&nbsp;edge&nbsp;tuples<br>
1211
&nbsp;&nbsp;&nbsp;&nbsp;Each&nbsp;edge&nbsp;given&nbsp;in&nbsp;the&nbsp;list&nbsp;or&nbsp;container&nbsp;will&nbsp;be&nbsp;removed&nbsp;<br>
1212
&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;the&nbsp;graph.&nbsp;The&nbsp;edges&nbsp;can&nbsp;be:<br>
1213
&nbsp;<br>
1214
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;2-tuples&nbsp;(u,v)&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
1215
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;3-tuples&nbsp;(u,v,k)&nbsp;where&nbsp;k&nbsp;is&nbsp;ignored.<br>
1216
&nbsp;<br>
1217
See&nbsp;Also<br>
1218
--------<br>
1219
remove_edge&nbsp;:&nbsp;remove&nbsp;a&nbsp;single&nbsp;edge<br>
1220
&nbsp;&nbsp;&nbsp;&nbsp;<br>
1221
Notes<br>
1222
-----<br>
1223
Will&nbsp;fail&nbsp;silently&nbsp;if&nbsp;an&nbsp;edge&nbsp;in&nbsp;ebunch&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph.<br>
1224
&nbsp;<br>
1225
Examples<br>
1226
--------<br>
1227
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1228
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
1229
&gt;&gt;&gt;&nbsp;ebunch=[(1,2),(2,3)]<br>
1230
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edges_from">remove_edges_from</a>(ebunch)</tt></dd></dl>
1231
 
1232
<dl><dt><a name="noc-remove_node"><strong>remove_node</strong></a>(self, n)</dt><dd><tt>Remove&nbsp;node&nbsp;n.<br>
1233
&nbsp;<br>
1234
Removes&nbsp;the&nbsp;node&nbsp;n&nbsp;and&nbsp;all&nbsp;adjacent&nbsp;edges.<br>
1235
Attempting&nbsp;to&nbsp;remove&nbsp;a&nbsp;non-existent&nbsp;node&nbsp;will&nbsp;raise&nbsp;an&nbsp;exception.<br>
1236
&nbsp;<br>
1237
Parameters<br>
1238
----------<br>
1239
n&nbsp;:&nbsp;node<br>
1240
&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;in&nbsp;the&nbsp;graph<br>
1241
&nbsp;<br>
1242
Raises<br>
1243
-------<br>
1244
NetworkXError<br>
1245
&nbsp;&nbsp;&nbsp;If&nbsp;n&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph.<br>
1246
&nbsp;<br>
1247
See&nbsp;Also<br>
1248
--------<br>
1249
remove_nodes_from<br>
1250
&nbsp;<br>
1251
Examples<br>
1252
--------<br>
1253
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1254
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
1255
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
1256
[(0,&nbsp;1),&nbsp;(1,&nbsp;2)]<br>
1257
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_node">remove_node</a>(1)<br>
1258
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
1259
[]</tt></dd></dl>
1260
 
1261
<dl><dt><a name="noc-remove_nodes_from"><strong>remove_nodes_from</strong></a>(self, nodes)</dt><dd><tt>Remove&nbsp;multiple&nbsp;nodes.<br>
1262
&nbsp;<br>
1263
Parameters<br>
1264
----------<br>
1265
nodes&nbsp;:&nbsp;iterable&nbsp;container<br>
1266
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes&nbsp;(list,&nbsp;<a href="__builtin__.html#dict">dict</a>,&nbsp;set,&nbsp;etc.).&nbsp;&nbsp;If&nbsp;a&nbsp;node<br>
1267
&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;the&nbsp;container&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph&nbsp;it&nbsp;is&nbsp;silently<br>
1268
&nbsp;&nbsp;&nbsp;&nbsp;ignored.<br>
1269
&nbsp;<br>
1270
See&nbsp;Also<br>
1271
--------<br>
1272
remove_node<br>
1273
&nbsp;<br>
1274
Examples<br>
1275
--------<br>
1276
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1277
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
1278
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
1279
&gt;&gt;&gt;&nbsp;e<br>
1280
[0,&nbsp;1,&nbsp;2]<br>
1281
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_nodes_from">remove_nodes_from</a>(e)<br>
1282
&gt;&gt;&gt;&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
1283
[]</tt></dd></dl>
1284
 
1285
<dl><dt><a name="noc-selfloop_edges"><strong>selfloop_edges</strong></a>(self, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;selfloop&nbsp;edges.<br>
1286
&nbsp;<br>
1287
A&nbsp;selfloop&nbsp;edge&nbsp;has&nbsp;the&nbsp;same&nbsp;node&nbsp;at&nbsp;both&nbsp;ends.<br>
1288
&nbsp;<br>
1289
Parameters<br>
1290
-----------<br>
1291
data&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
1292
&nbsp;&nbsp;&nbsp;&nbsp;Return&nbsp;selfloop&nbsp;edges&nbsp;as&nbsp;two&nbsp;tuples&nbsp;(u,v)&nbsp;(data=False)<br>
1293
&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;three-tuples&nbsp;(u,v,data)&nbsp;(data=True)<br>
1294
&nbsp;<br>
1295
Returns<br>
1296
-------<br>
1297
edgelist&nbsp;:&nbsp;list&nbsp;of&nbsp;edge&nbsp;tuples<br>
1298
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;all&nbsp;selfloop&nbsp;edges.<br>
1299
&nbsp;<br>
1300
See&nbsp;Also<br>
1301
--------<br>
1302
selfloop_nodes,&nbsp;number_of_selfloops<br>
1303
&nbsp;<br>
1304
Examples<br>
1305
--------<br>
1306
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1307
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,1)<br>
1308
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,2)<br>
1309
&gt;&gt;&gt;&nbsp;G.<a href="#noc-selfloop_edges">selfloop_edges</a>()<br>
1310
[(1,&nbsp;1)]<br>
1311
&gt;&gt;&gt;&nbsp;G.<a href="#noc-selfloop_edges">selfloop_edges</a>(data=True)<br>
1312
[(1,&nbsp;1,&nbsp;{})]</tt></dd></dl>
1313
 
1314
<dl><dt><a name="noc-size"><strong>size</strong></a>(self, weighted<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges.<br>
1315
&nbsp;<br>
1316
Parameters<br>
1317
----------<br>
1318
weighted&nbsp;:&nbsp;boolean,&nbsp;optional&nbsp;(default=False)<br>
1319
&nbsp;&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;the&nbsp;sum&nbsp;of&nbsp;the&nbsp;edge&nbsp;weights.<br>
1320
&nbsp;<br>
1321
Returns<br>
1322
-------<br>
1323
nedges&nbsp;:&nbsp;int<br>
1324
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;edges&nbsp;in&nbsp;the&nbsp;graph.<br>
1325
&nbsp;<br>
1326
See&nbsp;Also<br>
1327
--------<br>
1328
number_of_edges<br>
1329
&nbsp;<br>
1330
Examples<br>
1331
--------<br>
1332
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1333
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
1334
&gt;&gt;&gt;&nbsp;G.<a href="#noc-size">size</a>()<br>
1335
3<br>
1336
&nbsp;<br>
1337
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1338
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>('a','b',weight=2)<br>
1339
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>('b','c',weight=4)<br>
1340
&gt;&gt;&gt;&nbsp;G.<a href="#noc-size">size</a>()<br>
1341
2<br>
1342
&gt;&gt;&gt;&nbsp;G.<a href="#noc-size">size</a>(weighted=True)<br>
1343
6</tt></dd></dl>
1344
 
1345
<dl><dt><a name="noc-subgraph"><strong>subgraph</strong></a>(self, nbunch)</dt><dd><tt>Return&nbsp;the&nbsp;subgraph&nbsp;induced&nbsp;on&nbsp;nodes&nbsp;in&nbsp;nbunch.<br>
1346
&nbsp;<br>
1347
The&nbsp;induced&nbsp;subgraph&nbsp;of&nbsp;the&nbsp;graph&nbsp;contains&nbsp;the&nbsp;nodes&nbsp;in&nbsp;nbunch&nbsp;<br>
1348
and&nbsp;the&nbsp;edges&nbsp;between&nbsp;those&nbsp;nodes.&nbsp;&nbsp;<br>
1349
&nbsp;<br>
1350
Parameters<br>
1351
----------<br>
1352
nbunch&nbsp;:&nbsp;list,&nbsp;iterable<br>
1353
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes&nbsp;which&nbsp;will&nbsp;be&nbsp;iterated&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
1354
&nbsp;<br>
1355
Returns<br>
1356
-------<br>
1357
G&nbsp;:&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a><br>
1358
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;subgraph&nbsp;of&nbsp;the&nbsp;graph&nbsp;with&nbsp;the&nbsp;same&nbsp;edge&nbsp;attributes.&nbsp;&nbsp;<br>
1359
&nbsp;<br>
1360
Notes<br>
1361
-----<br>
1362
The&nbsp;graph,&nbsp;edge&nbsp;or&nbsp;node&nbsp;attributes&nbsp;just&nbsp;point&nbsp;to&nbsp;the&nbsp;original&nbsp;graph.<br>
1363
So&nbsp;changes&nbsp;to&nbsp;the&nbsp;node&nbsp;or&nbsp;edge&nbsp;structure&nbsp;will&nbsp;not&nbsp;be&nbsp;reflected&nbsp;in<br>
1364
the&nbsp;original&nbsp;graph&nbsp;while&nbsp;changes&nbsp;to&nbsp;the&nbsp;attributes&nbsp;will.<br>
1365
&nbsp;<br>
1366
To&nbsp;create&nbsp;a&nbsp;subgraph&nbsp;with&nbsp;its&nbsp;own&nbsp;copy&nbsp;of&nbsp;the&nbsp;edge/node&nbsp;attributes&nbsp;use:<br>
1367
nx.<a href="networkx.classes.graph.html#Graph">Graph</a>(G.<a href="#noc-subgraph">subgraph</a>(nbunch))<br>
1368
&nbsp;<br>
1369
If&nbsp;edge&nbsp;attributes&nbsp;are&nbsp;containers,&nbsp;a&nbsp;deep&nbsp;copy&nbsp;can&nbsp;be&nbsp;obtained&nbsp;using:<br>
1370
G.<a href="#noc-subgraph">subgraph</a>(nbunch).<a href="#noc-copy">copy</a>()<br>
1371
&nbsp;<br>
1372
For&nbsp;an&nbsp;in-place&nbsp;reduction&nbsp;of&nbsp;a&nbsp;graph&nbsp;to&nbsp;a&nbsp;subgraph&nbsp;you&nbsp;can&nbsp;remove&nbsp;nodes:<br>
1373
G.<a href="#noc-remove_nodes_from">remove_nodes_from</a>([&nbsp;n&nbsp;in&nbsp;G&nbsp;if&nbsp;n&nbsp;not&nbsp;in&nbsp;set(nbunch)])&nbsp;&nbsp;<br>
1374
&nbsp;<br>
1375
Examples<br>
1376
--------<br>
1377
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
1378
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
1379
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-subgraph">subgraph</a>([0,1,2])<br>
1380
&gt;&gt;&gt;&nbsp;print&nbsp;H.<a href="#noc-edges">edges</a>()<br>
1381
[(0,&nbsp;1),&nbsp;(1,&nbsp;2)]</tt></dd></dl>
1382
 
1383
<dl><dt><a name="noc-to_directed"><strong>to_directed</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;directed&nbsp;representation&nbsp;of&nbsp;the&nbsp;graph.<br>
1384
&nbsp;<br>
1385
Returns<br>
1386
-------<br>
1387
G&nbsp;:&nbsp;DiGraph<br>
1388
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;directed&nbsp;graph&nbsp;with&nbsp;the&nbsp;same&nbsp;name,&nbsp;same&nbsp;nodes,&nbsp;and&nbsp;with<br>
1389
&nbsp;&nbsp;&nbsp;&nbsp;each&nbsp;edge&nbsp;(u,v,data)&nbsp;replaced&nbsp;by&nbsp;two&nbsp;directed&nbsp;edges<br>
1390
&nbsp;&nbsp;&nbsp;&nbsp;(u,v,data)&nbsp;and&nbsp;(v,u,data).<br>
1391
&nbsp;<br>
1392
Notes<br>
1393
-----<br>
1394
This&nbsp;returns&nbsp;a&nbsp;"deepcopy"&nbsp;of&nbsp;the&nbsp;edge,&nbsp;node,&nbsp;and&nbsp;<br>
1395
graph&nbsp;attributes&nbsp;which&nbsp;attempts&nbsp;to&nbsp;completely&nbsp;copy<br>
1396
all&nbsp;of&nbsp;the&nbsp;data&nbsp;and&nbsp;references.<br>
1397
&nbsp;<br>
1398
This&nbsp;is&nbsp;in&nbsp;contrast&nbsp;to&nbsp;the&nbsp;similar&nbsp;D=DiGraph(G)&nbsp;which&nbsp;returns&nbsp;a&nbsp;<br>
1399
shallow&nbsp;copy&nbsp;of&nbsp;the&nbsp;data.&nbsp;<br>
1400
&nbsp;<br>
1401
See&nbsp;the&nbsp;Python&nbsp;copy&nbsp;module&nbsp;for&nbsp;more&nbsp;information&nbsp;on&nbsp;shallow<br>
1402
and&nbsp;deep&nbsp;copies,&nbsp;<a href="http://docs.python.org/library/copy.html">http://docs.python.org/library/copy.html</a>.<br>
1403
&nbsp;<br>
1404
Examples<br>
1405
--------<br>
1406
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiGraph,&nbsp;etc<br>
1407
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1])<br>
1408
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-to_directed">to_directed</a>()<br>
1409
&gt;&gt;&gt;&nbsp;H.<a href="#noc-edges">edges</a>()<br>
1410
[(0,&nbsp;1),&nbsp;(1,&nbsp;0)]<br>
1411
&nbsp;<br>
1412
If&nbsp;already&nbsp;directed,&nbsp;return&nbsp;a&nbsp;(deep)&nbsp;copy<br>
1413
&nbsp;<br>
1414
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.DiGraph()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiDiGraph,&nbsp;etc<br>
1415
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1])<br>
1416
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-to_directed">to_directed</a>()<br>
1417
&gt;&gt;&gt;&nbsp;H.<a href="#noc-edges">edges</a>()<br>
1418
[(0,&nbsp;1)]</tt></dd></dl>
1419
 
1420
<dl><dt><a name="noc-to_undirected"><strong>to_undirected</strong></a>(self)</dt><dd><tt>Return&nbsp;an&nbsp;undirected&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.&nbsp;<br>
1421
&nbsp;<br>
1422
Returns<br>
1423
-------<br>
1424
G&nbsp;:&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a>/MultiGraph<br>
1425
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;deepcopy&nbsp;of&nbsp;the&nbsp;graph.<br>
1426
&nbsp;<br>
1427
See&nbsp;Also<br>
1428
--------<br>
1429
copy,&nbsp;add_edge,&nbsp;add_edges_from<br>
1430
&nbsp;<br>
1431
Notes<br>
1432
-----<br>
1433
This&nbsp;returns&nbsp;a&nbsp;"deepcopy"&nbsp;of&nbsp;the&nbsp;edge,&nbsp;node,&nbsp;and&nbsp;<br>
1434
graph&nbsp;attributes&nbsp;which&nbsp;attempts&nbsp;to&nbsp;completely&nbsp;copy<br>
1435
all&nbsp;of&nbsp;the&nbsp;data&nbsp;and&nbsp;references.<br>
1436
&nbsp;<br>
1437
This&nbsp;is&nbsp;in&nbsp;contrast&nbsp;to&nbsp;the&nbsp;similar&nbsp;G=DiGraph(D)&nbsp;which&nbsp;returns&nbsp;a&nbsp;<br>
1438
shallow&nbsp;copy&nbsp;of&nbsp;the&nbsp;data.&nbsp;<br>
1439
&nbsp;<br>
1440
See&nbsp;the&nbsp;Python&nbsp;copy&nbsp;module&nbsp;for&nbsp;more&nbsp;information&nbsp;on&nbsp;shallow<br>
1441
and&nbsp;deep&nbsp;copies,&nbsp;<a href="http://docs.python.org/library/copy.html">http://docs.python.org/library/copy.html</a>.<br>
1442
&nbsp;<br>
1443
Examples<br>
1444
--------<br>
1445
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiGraph,&nbsp;etc<br>
1446
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1])<br>
1447
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-to_directed">to_directed</a>()<br>
1448
&gt;&gt;&gt;&nbsp;H.<a href="#noc-edges">edges</a>()<br>
1449
[(0,&nbsp;1),&nbsp;(1,&nbsp;0)]<br>
1450
&gt;&gt;&gt;&nbsp;G2&nbsp;=&nbsp;H.<a href="#noc-to_undirected">to_undirected</a>()<br>
1451
&gt;&gt;&gt;&nbsp;G2.<a href="#noc-edges">edges</a>()<br>
1452
[(0,&nbsp;1)]</tt></dd></dl>
1453
 
1454
<hr>
1455
Data descriptors inherited from <a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>:<br>
1456
<dl><dt><strong>__dict__</strong></dt>
1457
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
1458
</dl>
1459
<dl><dt><strong>__weakref__</strong></dt>
1460
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
1461
</dl>
1462
</td></tr></table> <p>
1463
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
1464
<tr bgcolor="#ffc8d8">
1465
<td colspan=3 valign=bottom>&nbsp;<br>
1466
<font color="#000000" face="helvetica, arial"><a name="nocobject">class <strong>nocobject</strong></a></font></td></tr>
1467
 
1468
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
1469
<td colspan=2><tt>NoC&nbsp;base&nbsp;object<br>
1470
&nbsp;<br>
1471
This&nbsp;base&nbsp;class&nbsp;is&nbsp;used&nbsp;to&nbsp;implement&nbsp;common&nbsp;methods&nbsp;for&nbsp;NoC&nbsp;objects.<br>
1472
Don't&nbsp;use&nbsp;directly.<br>&nbsp;</tt></td></tr>
1473
<tr><td>&nbsp;</td>
1474
<td width="100%">Methods defined here:<br>
1475
<dl><dt><a name="nocobject-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
1476
 
1477
</td></tr></table> <p>
1478
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
1479
<tr bgcolor="#ffc8d8">
1480
<td colspan=3 valign=bottom>&nbsp;<br>
1481
<font color="#000000" face="helvetica, arial"><a name="packet">class <strong>packet</strong></a>(<a href="__builtin__.html#dict">__builtin__.dict</a>)</font></td></tr>
1482
 
1483
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
1484
<td colspan=2><tt>Packet&nbsp;base&nbsp;object<br>
1485
&nbsp;<br>
1486
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;<a href="#packet">packet</a>&nbsp;data,&nbsp;related&nbsp;to&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object.&nbsp;It&nbsp;<br>
1487
behaves&nbsp;exactly&nbsp;like&nbsp;a&nbsp;Python&nbsp;dictionary,&nbsp;but&nbsp;adds&nbsp;methods&nbsp;to&nbsp;simplify&nbsp;<br>
1488
<a href="#packet">packet</a>&nbsp;transformations.&nbsp;&nbsp;&nbsp;&nbsp;<br>
1489
&nbsp;<br>
1490
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
1491
*&nbsp;It&nbsp;should&nbsp;be&nbsp;generated&nbsp;by&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;(and&nbsp;will&nbsp;have&nbsp;a&nbsp;reference&nbsp;<br>
1492
&nbsp;&nbsp;in&nbsp;self.<strong>protocol_ref</strong>)<br>
1493
&nbsp;<br>
1494
Attributes:<br>
1495
*&nbsp;protocol_ref:&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;that&nbsp;created&nbsp;this&nbsp;object.<br>&nbsp;</tt></td></tr>
1496
<tr><td>&nbsp;</td>
1497
<td width="100%"><dl><dt>Method resolution order:</dt>
1498
<dd><a href="nocmodel.noc_base.html#packet">packet</a></dd>
1499
<dd><a href="__builtin__.html#dict">__builtin__.dict</a></dd>
1500
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
1501
</dl>
1502
<hr>
1503
Methods defined here:<br>
1504
<dl><dt><a name="packet-__init__"><strong>__init__</strong></a>(self, *args, **kwargs)</dt><dd><tt>#&nbsp;the&nbsp;constructor</tt></dd></dl>
1505
 
1506
<hr>
1507
Data descriptors defined here:<br>
1508
<dl><dt><strong>__dict__</strong></dt>
1509
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
1510
</dl>
1511
<dl><dt><strong>__weakref__</strong></dt>
1512
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
1513
</dl>
1514
<hr>
1515
Methods inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
1516
<dl><dt><a name="packet-__cmp__"><strong>__cmp__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__cmp__">__cmp__</a>(y)&nbsp;&lt;==&gt;&nbsp;cmp(x,y)</tt></dd></dl>
1517
 
1518
<dl><dt><a name="packet-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>D.<a href="#packet-__contains__">__contains__</a>(k)&nbsp;-&gt;&nbsp;True&nbsp;if&nbsp;D&nbsp;has&nbsp;a&nbsp;key&nbsp;k,&nbsp;else&nbsp;False</tt></dd></dl>
1519
 
1520
<dl><dt><a name="packet-__delitem__"><strong>__delitem__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__delitem__">__delitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;del&nbsp;x[y]</tt></dd></dl>
1521
 
1522
<dl><dt><a name="packet-__eq__"><strong>__eq__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__eq__">__eq__</a>(y)&nbsp;&lt;==&gt;&nbsp;x==y</tt></dd></dl>
1523
 
1524
<dl><dt><a name="packet-__ge__"><strong>__ge__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__ge__">__ge__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&gt;=y</tt></dd></dl>
1525
 
1526
<dl><dt><a name="packet-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__getattribute__">__getattribute__</a>('name')&nbsp;&lt;==&gt;&nbsp;x.name</tt></dd></dl>
1527
 
1528
<dl><dt><a name="packet-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>
1529
 
1530
<dl><dt><a name="packet-__gt__"><strong>__gt__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__gt__">__gt__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&gt;y</tt></dd></dl>
1531
 
1532
<dl><dt><a name="packet-__iter__"><strong>__iter__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__iter__">__iter__</a>()&nbsp;&lt;==&gt;&nbsp;iter(x)</tt></dd></dl>
1533
 
1534
<dl><dt><a name="packet-__le__"><strong>__le__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__le__">__le__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&lt;=y</tt></dd></dl>
1535
 
1536
<dl><dt><a name="packet-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__len__">__len__</a>()&nbsp;&lt;==&gt;&nbsp;len(x)</tt></dd></dl>
1537
 
1538
<dl><dt><a name="packet-__lt__"><strong>__lt__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__lt__">__lt__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&lt;y</tt></dd></dl>
1539
 
1540
<dl><dt><a name="packet-__ne__"><strong>__ne__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__ne__">__ne__</a>(y)&nbsp;&lt;==&gt;&nbsp;x!=y</tt></dd></dl>
1541
 
1542
<dl><dt><a name="packet-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>
1543
 
1544
<dl><dt><a name="packet-__setitem__"><strong>__setitem__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__setitem__">__setitem__</a>(i,&nbsp;y)&nbsp;&lt;==&gt;&nbsp;x[i]=y</tt></dd></dl>
1545
 
1546
<dl><dt><a name="packet-__sizeof__"><strong>__sizeof__</strong></a>(...)</dt><dd><tt>D.<a href="#packet-__sizeof__">__sizeof__</a>()&nbsp;-&gt;&nbsp;size&nbsp;of&nbsp;D&nbsp;in&nbsp;memory,&nbsp;in&nbsp;bytes</tt></dd></dl>
1547
 
1548
<dl><dt><a name="packet-clear"><strong>clear</strong></a>(...)</dt><dd><tt>D.<a href="#packet-clear">clear</a>()&nbsp;-&gt;&nbsp;None.&nbsp;&nbsp;Remove&nbsp;all&nbsp;items&nbsp;from&nbsp;D.</tt></dd></dl>
1549
 
1550
<dl><dt><a name="packet-copy"><strong>copy</strong></a>(...)</dt><dd><tt>D.<a href="#packet-copy">copy</a>()&nbsp;-&gt;&nbsp;a&nbsp;shallow&nbsp;copy&nbsp;of&nbsp;D</tt></dd></dl>
1551
 
1552
<dl><dt><a name="packet-get"><strong>get</strong></a>(...)</dt><dd><tt>D.<a href="#packet-get">get</a>(k[,d])&nbsp;-&gt;&nbsp;D[k]&nbsp;if&nbsp;k&nbsp;in&nbsp;D,&nbsp;else&nbsp;d.&nbsp;&nbsp;d&nbsp;defaults&nbsp;to&nbsp;None.</tt></dd></dl>
1553
 
1554
<dl><dt><a name="packet-has_key"><strong>has_key</strong></a>(...)</dt><dd><tt>D.<a href="#packet-has_key">has_key</a>(k)&nbsp;-&gt;&nbsp;True&nbsp;if&nbsp;D&nbsp;has&nbsp;a&nbsp;key&nbsp;k,&nbsp;else&nbsp;False</tt></dd></dl>
1555
 
1556
<dl><dt><a name="packet-items"><strong>items</strong></a>(...)</dt><dd><tt>D.<a href="#packet-items">items</a>()&nbsp;-&gt;&nbsp;list&nbsp;of&nbsp;D's&nbsp;(key,&nbsp;value)&nbsp;pairs,&nbsp;as&nbsp;2-tuples</tt></dd></dl>
1557
 
1558
<dl><dt><a name="packet-iteritems"><strong>iteritems</strong></a>(...)</dt><dd><tt>D.<a href="#packet-iteritems">iteritems</a>()&nbsp;-&gt;&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;(key,&nbsp;value)&nbsp;items&nbsp;of&nbsp;D</tt></dd></dl>
1559
 
1560
<dl><dt><a name="packet-iterkeys"><strong>iterkeys</strong></a>(...)</dt><dd><tt>D.<a href="#packet-iterkeys">iterkeys</a>()&nbsp;-&gt;&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;keys&nbsp;of&nbsp;D</tt></dd></dl>
1561
 
1562
<dl><dt><a name="packet-itervalues"><strong>itervalues</strong></a>(...)</dt><dd><tt>D.<a href="#packet-itervalues">itervalues</a>()&nbsp;-&gt;&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;values&nbsp;of&nbsp;D</tt></dd></dl>
1563
 
1564
<dl><dt><a name="packet-keys"><strong>keys</strong></a>(...)</dt><dd><tt>D.<a href="#packet-keys">keys</a>()&nbsp;-&gt;&nbsp;list&nbsp;of&nbsp;D's&nbsp;keys</tt></dd></dl>
1565
 
1566
<dl><dt><a name="packet-pop"><strong>pop</strong></a>(...)</dt><dd><tt>D.<a href="#packet-pop">pop</a>(k[,d])&nbsp;-&gt;&nbsp;v,&nbsp;remove&nbsp;specified&nbsp;key&nbsp;and&nbsp;return&nbsp;the&nbsp;corresponding&nbsp;value.<br>
1567
If&nbsp;key&nbsp;is&nbsp;not&nbsp;found,&nbsp;d&nbsp;is&nbsp;returned&nbsp;if&nbsp;given,&nbsp;otherwise&nbsp;KeyError&nbsp;is&nbsp;raised</tt></dd></dl>
1568
 
1569
<dl><dt><a name="packet-popitem"><strong>popitem</strong></a>(...)</dt><dd><tt>D.<a href="#packet-popitem">popitem</a>()&nbsp;-&gt;&nbsp;(k,&nbsp;v),&nbsp;remove&nbsp;and&nbsp;return&nbsp;some&nbsp;(key,&nbsp;value)&nbsp;pair&nbsp;as&nbsp;a<br>
1570
2-tuple;&nbsp;but&nbsp;raise&nbsp;KeyError&nbsp;if&nbsp;D&nbsp;is&nbsp;empty.</tt></dd></dl>
1571
 
1572
<dl><dt><a name="packet-setdefault"><strong>setdefault</strong></a>(...)</dt><dd><tt>D.<a href="#packet-setdefault">setdefault</a>(k[,d])&nbsp;-&gt;&nbsp;D.<a href="#packet-get">get</a>(k,d),&nbsp;also&nbsp;set&nbsp;D[k]=d&nbsp;if&nbsp;k&nbsp;not&nbsp;in&nbsp;D</tt></dd></dl>
1573
 
1574
<dl><dt><a name="packet-update"><strong>update</strong></a>(...)</dt><dd><tt>D.<a href="#packet-update">update</a>(E,&nbsp;**F)&nbsp;-&gt;&nbsp;None.&nbsp;&nbsp;Update&nbsp;D&nbsp;from&nbsp;<a href="__builtin__.html#dict">dict</a>/iterable&nbsp;E&nbsp;and&nbsp;F.<br>
1575
If&nbsp;E&nbsp;has&nbsp;a&nbsp;.<a href="#packet-keys">keys</a>()&nbsp;method,&nbsp;does:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;k&nbsp;in&nbsp;E:&nbsp;D[k]&nbsp;=&nbsp;E[k]<br>
1576
If&nbsp;E&nbsp;lacks&nbsp;.<a href="#packet-keys">keys</a>()&nbsp;method,&nbsp;does:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(k,&nbsp;v)&nbsp;in&nbsp;E:&nbsp;D[k]&nbsp;=&nbsp;v<br>
1577
In&nbsp;either&nbsp;case,&nbsp;this&nbsp;is&nbsp;followed&nbsp;by:&nbsp;for&nbsp;k&nbsp;in&nbsp;F:&nbsp;D[k]&nbsp;=&nbsp;F[k]</tt></dd></dl>
1578
 
1579
<dl><dt><a name="packet-values"><strong>values</strong></a>(...)</dt><dd><tt>D.<a href="#packet-values">values</a>()&nbsp;-&gt;&nbsp;list&nbsp;of&nbsp;D's&nbsp;values</tt></dd></dl>
1580
 
1581
<hr>
1582
Data and other attributes inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
1583
<dl><dt><strong>__hash__</strong> = None</dl>
1584
 
1585
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object&gt;<dd><tt>T.<a href="#packet-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;object&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>
1586
 
1587
<dl><dt><strong>fromkeys</strong> = &lt;built-in method fromkeys of type object&gt;<dd><tt><a href="__builtin__.html#dict">dict</a>.<a href="#packet-fromkeys">fromkeys</a>(S[,v])&nbsp;-&gt;&nbsp;New&nbsp;<a href="__builtin__.html#dict">dict</a>&nbsp;with&nbsp;keys&nbsp;from&nbsp;S&nbsp;and&nbsp;values&nbsp;equal&nbsp;to&nbsp;v.<br>
1588
v&nbsp;defaults&nbsp;to&nbsp;None.</tt></dl>
1589
 
1590
</td></tr></table> <p>
1591
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
1592
<tr bgcolor="#ffc8d8">
1593
<td colspan=3 valign=bottom>&nbsp;<br>
1594
<font color="#000000" face="helvetica, arial"><a name="protocol">class <strong>protocol</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
1595
 
1596
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
1597
<td colspan=2><tt>Protocol&nbsp;base&nbsp;object<br>
1598
&nbsp;<br>
1599
This&nbsp;object&nbsp;represents&nbsp;the&nbsp;<a href="#protocol">protocol</a>&nbsp;that&nbsp;the&nbsp;NoC&nbsp;objects&nbsp;use.&nbsp;This&nbsp;<br>
1600
object&nbsp;has&nbsp;attributes&nbsp;that&nbsp;define&nbsp;the&nbsp;<a href="#protocol">protocol</a>&nbsp;used,&nbsp;mainly&nbsp;it&nbsp;can&nbsp;be<br>
1601
used&nbsp;to&nbsp;generate,&nbsp;encode,&nbsp;decode&nbsp;or&nbsp;interpret&nbsp;packets&nbsp;on&nbsp;the&nbsp;NoC.<br>
1602
This&nbsp;base&nbsp;class&nbsp;can&nbsp;be&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;<br>
1603
other&nbsp;attributes.<br>
1604
&nbsp;<br>
1605
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
1606
*&nbsp;Each&nbsp;object&nbsp;on&nbsp;the&nbsp;NoC&nbsp;(routers,&nbsp;channels&nbsp;and&nbsp;ipcores)&nbsp;may&nbsp;have<br>
1607
&nbsp;&nbsp;one&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;(object.protocol_ref)<br>
1608
*&nbsp;A&nbsp;NoC&nbsp;model&nbsp;may&nbsp;have&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object:&nbsp;in&nbsp;this&nbsp;case,&nbsp;all&nbsp;objects&nbsp;in<br>
1609
&nbsp;&nbsp;the&nbsp;model&nbsp;will&nbsp;use&nbsp;this&nbsp;<a href="#protocol">protocol</a>&nbsp;(nocmodel.protocol_ref)<br>
1610
*&nbsp;A&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;is&nbsp;a&nbsp;generator&nbsp;of&nbsp;<a href="#packet">packet</a>&nbsp;objects<br>
1611
&nbsp;<br>
1612
Attributes:<br>
1613
*&nbsp;name<br>
1614
&nbsp;<br>
1615
Notes:&nbsp;<br>
1616
*&nbsp;Optional&nbsp;arguments&nbsp;"packet_format"&nbsp;and&nbsp;"packet_order"&nbsp;can&nbsp;be<br>
1617
&nbsp;&nbsp;added&nbsp;at&nbsp;object&nbsp;construction,&nbsp;but&nbsp;will&nbsp;not&nbsp;check&nbsp;its&nbsp;data&nbsp;consistency.&nbsp;<br>
1618
&nbsp;&nbsp;At&nbsp;the&nbsp;moment,&nbsp;we&nbsp;recommend&nbsp;using&nbsp;<a href="#protocol-update_packet_field">update_packet_field</a>()&nbsp;method&nbsp;to<br>
1619
&nbsp;&nbsp;fill&nbsp;this&nbsp;data&nbsp;structures.<br>&nbsp;</tt></td></tr>
1620
<tr><td>&nbsp;</td>
1621
<td width="100%">Methods defined here:<br>
1622
<dl><dt><a name="protocol-__init__"><strong>__init__</strong></a>(self, name<font color="#909090">=''</font>, **kwargs)</dt><dd><tt>Constructor<br>
1623
&nbsp;<br>
1624
Notes:<br>
1625
*&nbsp;Optional&nbsp;arguments&nbsp;will&nbsp;be&nbsp;added&nbsp;as&nbsp;object&nbsp;attributes.</tt></dd></dl>
1626
 
1627
<dl><dt><a name="protocol-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt></dl>
1628
 
1629
<dl><dt><a name="protocol-newpacket"><strong>newpacket</strong></a>(self, zerodefault<font color="#909090">=True</font>, *args, **kwargs)</dt><dd><tt>Return&nbsp;a&nbsp;new&nbsp;<a href="#packet">packet</a>&nbsp;with&nbsp;all&nbsp;required&nbsp;fields.<br>
1630
&nbsp;<br>
1631
Arguments:<br>
1632
*&nbsp;zerodefault:&nbsp;If&nbsp;True,&nbsp;all&nbsp;missing&nbsp;fields&nbsp;will&nbsp;be&nbsp;zeroed&nbsp;by&nbsp;default.<br>
1633
&nbsp;&nbsp;If&nbsp;False,&nbsp;a&nbsp;missing&nbsp;value&nbsp;in&nbsp;arguments&nbsp;will&nbsp;throw&nbsp;an&nbsp;exception.<br>
1634
*&nbsp;args:&nbsp;Nameless&nbsp;arguments&nbsp;will&nbsp;add&nbsp;field&nbsp;values&nbsp;based&nbsp;on&nbsp;<a href="#packet">packet</a>&nbsp;field<br>
1635
&nbsp;&nbsp;order.<br>
1636
*&nbsp;kwargs:&nbsp;Key-based&nbsp;arguments&nbsp;will&nbsp;add&nbsp;specified&nbsp;field&nbsp;values&nbsp;based&nbsp;in&nbsp;<br>
1637
&nbsp;&nbsp;its&nbsp;keys<br>
1638
&nbsp;&nbsp;&nbsp;&nbsp;<br>
1639
Notes:&nbsp;<br>
1640
*&nbsp;kwargs&nbsp;takes&nbsp;precedence&nbsp;over&nbsp;args:&nbsp;i.e.&nbsp;named&nbsp;arguments&nbsp;can&nbsp;overwrite<br>
1641
&nbsp;&nbsp;nameless&nbsp;arguments.</tt></dd></dl>
1642
 
1643
<dl><dt><a name="protocol-register_packet_generator"><strong>register_packet_generator</strong></a>(self, packet_class)</dt><dd><tt>Register&nbsp;a&nbsp;special&nbsp;<a href="#packet">packet</a>&nbsp;generator&nbsp;class.<br>
1644
&nbsp;<br>
1645
Must&nbsp;be&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;<a href="#packet">packet</a></tt></dd></dl>
1646
 
1647
<dl><dt><a name="protocol-update_packet_field"><strong>update_packet_field</strong></a>(self, name, type, bitlen, description<font color="#909090">=''</font>)</dt><dd><tt>Add&nbsp;or&nbsp;update&nbsp;a&nbsp;<a href="#packet">packet</a>&nbsp;field.<br>
1648
&nbsp;<br>
1649
Arguments<br>
1650
*&nbsp;name<br>
1651
*&nbsp;type:&nbsp;string&nbsp;that&nbsp;can&nbsp;be&nbsp;"int",&nbsp;"fixed"&nbsp;or&nbsp;"float"<br>
1652
*&nbsp;bitlen:&nbsp;bit&nbsp;length&nbsp;of&nbsp;this&nbsp;field<br>
1653
*&nbsp;description:&nbsp;optional&nbsp;description&nbsp;of&nbsp;this&nbsp;field<br>
1654
&nbsp;<br>
1655
Notes:&nbsp;<br>
1656
*&nbsp;Each&nbsp;new&nbsp;field&nbsp;will&nbsp;be&nbsp;added&nbsp;at&nbsp;the&nbsp;end.</tt></dd></dl>
1657
 
1658
</td></tr></table> <p>
1659
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
1660
<tr bgcolor="#ffc8d8">
1661
<td colspan=3 valign=bottom>&nbsp;<br>
1662
<font color="#000000" face="helvetica, arial"><a name="router">class <strong>router</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
1663
 
1664
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
1665
<td colspan=2><tt>Router&nbsp;base&nbsp;object<br>
1666
&nbsp;<br>
1667
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;and&nbsp;its&nbsp;properties.&nbsp;This&nbsp;base&nbsp;class<br>
1668
is&nbsp;meant&nbsp;to&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;other&nbsp;attributes.<br>
1669
&nbsp;<br>
1670
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
1671
*&nbsp;It&nbsp;should&nbsp;be&nbsp;related&nbsp;to&nbsp;one&nbsp;NoC&nbsp;model&nbsp;object&nbsp;(self.<strong>graph_ref</strong>)<br>
1672
*&nbsp;It&nbsp;should&nbsp;be&nbsp;one&nbsp;of&nbsp;the&nbsp;node&nbsp;attributes&nbsp;in&nbsp;the&nbsp;graph&nbsp;model&nbsp;<br>
1673
&nbsp;&nbsp;(node["router_ref"])<br>
1674
*&nbsp;It&nbsp;may&nbsp;have&nbsp;one&nbsp;reference&nbsp;to&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;(self.<strong>ipcore_ref</strong>)<br>
1675
*&nbsp;It&nbsp;has&nbsp;a&nbsp;port&nbsp;list&nbsp;with&nbsp;relations&nbsp;to&nbsp;other&nbsp;routers&nbsp;through&nbsp;<a href="#channel">channel</a>&nbsp;objects,<br>
1676
&nbsp;&nbsp;and&nbsp;only&nbsp;one&nbsp;relation&nbsp;to&nbsp;its&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;through&nbsp;one&nbsp;<a href="#channel">channel</a>.<br>
1677
&nbsp;&nbsp;(self.<strong>ports</strong>).&nbsp;Note&nbsp;that&nbsp;this&nbsp;attribute&nbsp;must&nbsp;be&nbsp;updated&nbsp;after&nbsp;changing&nbsp;<br>
1678
&nbsp;&nbsp;the&nbsp;NoC&nbsp;model.<br>
1679
&nbsp;<br>
1680
Attributes:<br>
1681
*&nbsp;index:&nbsp;index&nbsp;on&nbsp;a&nbsp;<a href="#noc">noc</a>&nbsp;object.&nbsp;Essential&nbsp;to&nbsp;search&nbsp;for&nbsp;a&nbsp;<a href="#router">router</a>&nbsp;object<br>
1682
*&nbsp;name<br>
1683
*&nbsp;ipcore_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;related&nbsp;<a href="#ipcore">ipcore</a><br>
1684
*&nbsp;graph_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;graph&nbsp;model<br>&nbsp;</tt></td></tr>
1685
<tr><td>&nbsp;</td>
1686
<td width="100%">Methods defined here:<br>
1687
<dl><dt><a name="router-__init__"><strong>__init__</strong></a>(self, index, name, **kwargs)</dt></dl>
1688
 
1689
<dl><dt><a name="router-update_ports_info"><strong>update_ports_info</strong></a>(self)</dt><dd><tt>Update&nbsp;the&nbsp;dictionary&nbsp;"ports":&nbsp;information&nbsp;about&nbsp;<a href="#router">router</a>&nbsp;neighbors,<br>
1690
the&nbsp;channels&nbsp;that&nbsp;connect&nbsp;them&nbsp;and&nbsp;its&nbsp;references.<br>
1691
&nbsp;<br>
1692
Ports&nbsp;dictionary&nbsp;has&nbsp;the&nbsp;following&nbsp;structure:<br>
1693
*&nbsp;key:&nbsp;address&nbsp;of&nbsp;the&nbsp;neighbor&nbsp;<a href="#router">router</a>&nbsp;that&nbsp;this&nbsp;port&nbsp;connects.<br>
1694
*&nbsp;value:&nbsp;dictionary&nbsp;with&nbsp;the&nbsp;following&nbsp;keys:<br>
1695
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"peer"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;the&nbsp;neighbor&nbsp;<a href="#router">router</a><br>
1696
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"<a href="#channel">channel</a>"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;that&nbsp;connects&nbsp;this&nbsp;<br>
1697
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#router">router</a>&nbsp;and&nbsp;its&nbsp;neighbor&nbsp;<a href="#router">router</a>.<br>
1698
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Optional&nbsp;keys&nbsp;can&nbsp;be&nbsp;added&nbsp;to&nbsp;this&nbsp;dictionary.<br>
1699
*&nbsp;Also,&nbsp;the&nbsp;special&nbsp;key&nbsp;"local&nbsp;address"&nbsp;holds&nbsp;the&nbsp;port&nbsp;to&nbsp;<br>
1700
&nbsp;&nbsp;<a href="#router">router</a>'s&nbsp;<a href="#ipcore">ipcore</a>.&nbsp;Its&nbsp;values&nbsp;are:<br>
1701
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"peer"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;its&nbsp;<a href="#ipcore">ipcore</a><br>
1702
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"<a href="#channel">channel</a>"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;that&nbsp;connects&nbsp;this&nbsp;<br>
1703
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#router">router</a>&nbsp;and&nbsp;its&nbsp;<a href="#ipcore">ipcore</a>.<br>
1704
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Optional&nbsp;keys&nbsp;can&nbsp;be&nbsp;added&nbsp;to&nbsp;this&nbsp;dictionary&nbsp;with&nbsp;the&nbsp;same&nbsp;<br>
1705
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;meaning&nbsp;as&nbsp;other&nbsp;ports.</tt></dd></dl>
1706
 
1707
<dl><dt><a name="router-update_routes_info"><strong>update_routes_info</strong></a>(self)</dt><dd><tt>Update&nbsp;the&nbsp;dictionary&nbsp;"routes_info":&nbsp;it&nbsp;is&nbsp;a&nbsp;table&nbsp;with&nbsp;information&nbsp;<br>
1708
about&nbsp;how&nbsp;a&nbsp;package,&nbsp;starting&nbsp;from&nbsp;this&nbsp;<a href="#router">router</a>,&nbsp;can&nbsp;reach&nbsp;another&nbsp;one.<br>
1709
&nbsp;<br>
1710
routes_info&nbsp;dictionary&nbsp;has&nbsp;the&nbsp;following&nbsp;structure:<br>
1711
*&nbsp;keys&nbsp;:&nbsp;the&nbsp;address&nbsp;of&nbsp;all&nbsp;the&nbsp;routers&nbsp;in&nbsp;NoC<br>
1712
*&nbsp;values&nbsp;:&nbsp;an&nbsp;ordered&nbsp;list&nbsp;of&nbsp;dictionaries&nbsp;with&nbsp;<br>
1713
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"next"&nbsp;:&nbsp;address&nbsp;of&nbsp;the&nbsp;next&nbsp;<a href="#router">router</a><br>
1714
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"paths"&nbsp;:&nbsp;list&nbsp;of&nbsp;possible&nbsp;paths&nbsp;for&nbsp;key&nbsp;destination</tt></dd></dl>
1715
 
1716
<hr>
1717
Methods inherited from <a href="nocmodel.noc_base.html#nocobject">nocobject</a>:<br>
1718
<dl><dt><a name="router-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
1719
 
1720
</td></tr></table></td></tr></table><p>
1721
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
1722
<tr bgcolor="#eeaa77">
1723
<td colspan=3 valign=bottom>&nbsp;<br>
1724
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
1725
 
1726
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
1727
<td width="100%"><dl><dt><a name="-all_shortest_paths"><strong>all_shortest_paths</strong></a>(G, a, b)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;all&nbsp;shortest&nbsp;paths&nbsp;in&nbsp;graph&nbsp;G&nbsp;between&nbsp;nodes&nbsp;a&nbsp;and&nbsp;b<br>
1728
This&nbsp;is&nbsp;a&nbsp;function&nbsp;not&nbsp;available&nbsp;in&nbsp;NetworkX&nbsp;(checked&nbsp;at&nbsp;22-02-2011)<br>
1729
&nbsp;<br>
1730
Taken&nbsp;from:&nbsp;<br>
1731
<a href="http://groups.google.com/group/networkx-discuss/browse_thread/thread/55465e6bb9bae12e">http://groups.google.com/group/networkx-discuss/browse_thread/thread/55465e6bb9bae12e</a></tt></dd></dl>
1732
</td></tr></table>
1733
</body></html>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.