File: digraph.html

package info (click to toggle)
erlang-doc-html 1%3A8.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 18,028 kB
  • ctags: 7,419
  • sloc: perl: 1,841; ansic: 323; erlang: 155
file content (555 lines) | stat: -rw-r--r-- 21,237 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>digraph</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>


<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>digraph</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
digraph</UL>
<H3>MODULE SUMMARY</H3>
<UL>
Directed Graphs</UL>
<H3>DESCRIPTION</H3>
<UL>
<P>The <CODE>digraph</CODE> module implements a version of labeled
directed graphs. What makes the graphs implemented here
non-proper directed graphs is that multiple edges between
vertices are allowed. However, the customary definition of
directed graphs will be used in the text that follows.



<P>A <A NAME="digraph"><!-- Empty --></A><STRONG>directed graph</STRONG> (or just
&#34;digraph&#34;) is a pair (V,&#160;E) of a finite set V of <A NAME="vertex"><!-- Empty --></A><STRONG>vertices</STRONG> and a finite set E of <A NAME="edge"><!-- Empty --></A><STRONG>directed edges</STRONG> (or just &#34;edges&#34;). The set of
edges E is a subset of V&#160;&#215;&#160;V (the Cartesian
product of V with itself). In this module, V is allowed to be
empty; the so obtained unique digraph is called the <A NAME="empty_digraph"><!-- Empty --></A> <STRONG>empty digraph</STRONG>. Both vertices and
edges are represented by unique Erlang terms.

<P>Digraphs can be annotated with additional information. Such
information may be attached to the vertices and to the edges of
the digraph. A digraph which has been annotated is called a
<STRONG>labeled digraph</STRONG>, and the information attached to a
vertex or an edge is called a <A NAME="label"><!-- Empty --></A><STRONG>label</STRONG>.
Labels are Erlang terms.

<P>An edge e&#160;=&#160;(v,&#160;w) is said to <A NAME="emanate"><!-- Empty --></A><STRONG>emanate</STRONG> from vertex v and to be <A NAME="incident"><!-- Empty --></A><STRONG>incident</STRONG> on vertex w. The <A NAME="out_degree"><!-- Empty --></A><STRONG>out-degree</STRONG> of a vertex is the number of
edges emanating from that vertex. The <A NAME="in_degree"><!-- Empty --></A><STRONG>in-degree</STRONG> of a vertex is the number of
edges incident on that vertex. If there is an edge emanating
from v and incident on w, then w is is said to be an <A NAME="out_neighbour"><!-- Empty --></A><STRONG>out-neighbour</STRONG> of v, and v is said to
be an <A NAME="in_neighbour"><!-- Empty --></A><STRONG>in-neighbour</STRONG> of w. A
<A NAME="path"><!-- Empty --></A><STRONG>path</STRONG> P from v[1] to v[k] in a digraph
(V, E) is a non-empty sequence
v[1],&#160;v[2],&#160;...,&#160;v[k] of vertices in V such that
there is an edge (v[i],v[i+1]) in E for
1&#160;&#60;=&#160;i&#160;&#60;&#160;k. The <A NAME="length"><!-- Empty --></A><STRONG>length</STRONG> of the path P is k-1. P is <A NAME="simple_path"><!-- Empty --></A><STRONG>simple</STRONG> if all vertices are distinct,
except that the first and the last vertices may be the same. P
is a <A NAME="cycle"><!-- Empty --></A><STRONG>cycle</STRONG> if the length of P is not
zero and v[1] = v[k]. A <A NAME="loop"><!-- Empty --></A><STRONG>loop</STRONG> is a
cycle of length one. A <A NAME="simple_cycle"><!-- Empty --></A><STRONG>simple
cycle</STRONG> is a path that is both a cycle and simple. An <A NAME="acyclic_digraph"><!-- Empty --></A><STRONG>acyclic digraph</STRONG> is a digraph that
has no cycles.

</UL>
<H3>EXPORTS</H3>
<P><A NAME="add_edge%5"><STRONG><CODE>add_edge(G, E, V1, V2, Label) -&#62; edge() | {error, Reason}</CODE></STRONG></A><BR>
<A NAME="add_edge%4"><STRONG><CODE>add_edge(G, V1, V2, Label) -&#62; edge() | {error, Reason}</CODE></STRONG></A><BR>
<A NAME="add_edge%3"><STRONG><CODE>add_edge(G, V1, V2) -&#62; edge() | {error, Reason}</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>E = edge()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Label = label()</CODE></STRONG><BR>
<STRONG><CODE>Reason = {bad_edge, Path} | {bad_vertex, V}</CODE></STRONG><BR>
<STRONG><CODE>Path = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P><CODE>add_edge/5</CODE> creates (or modifies) the edge <CODE>E</CODE>
         of the digraph <CODE>G</CODE>, using <CODE>Label</CODE> as the (new)
         <A HREF="#label">label</A> of the edge. The
         edge is <A HREF="#emanate">emanating</A> from
         <CODE>V1</CODE> and <A HREF="#incident">incident</A>
         on <CODE>V2</CODE>. Returns <CODE>E</CODE>.

        <P><CODE>add_edge(G,&#160;V1,&#160;V2,&#160;Label)</CODE> is
         equivalent to
         <CODE>add_edge(G,&#160;E,&#160;V1,&#160;V2,&#160;Label)</CODE>,
         where <CODE>E</CODE> is a created edge. Tuples on the form
         <CODE>['$e'&#160;|&#160;N]</CODE>, where N is an
         integer&#160;&#62;=&#160;1, are used for representing the
         created edges.

        <P><CODE>add_edge(G,&#160;V1,&#160;V2)</CODE> is equivalent to
         <CODE>add_edge(G,&#160;V1,&#160;V2,&#160;[])</CODE>.

        <P>If the edge would create a cycle in an <A HREF="#acyclic_digraph">acyclic digraph</A>, then
         <CODE>{error,&#160;{bad_edge,&#160;Path}}</CODE> is returned. If
         either of <CODE>V1</CODE> or <CODE>V2</CODE> is not a vertex of the
         digraph <CODE>G</CODE>, then
         <CODE>{error,&#160;{bad_vertex,&#160;</CODE>V<CODE>}}</CODE> is
         returned, V&#160;=&#160;<CODE>V1</CODE> or
         V&#160;=&#160;<CODE>V2</CODE>.

</UL>
<P><A NAME="add_vertex%3"><STRONG><CODE>add_vertex(G, V, Label) -&#62; vertex()</CODE></STRONG></A><BR>
<A NAME="add_vertex%2"><STRONG><CODE>add_vertex(G, V) -&#62; vertex()</CODE></STRONG></A><BR>
<A NAME="add_vertex%1"><STRONG><CODE>add_vertex(G) -&#62; vertex()</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Label = label()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P><CODE>add_vertex/3</CODE> creates (or modifies) the vertex <CODE>V</CODE>
         of the digraph <CODE>G</CODE>, using <CODE>Label</CODE> as the (new)
         <A HREF="#label">label</A> of the
         vertex. Returns <CODE>V</CODE>.

        <P><CODE>add_vertex(G,&#160;V)</CODE> is equivalent to
         <CODE>add_vertex(G,&#160;V,&#160;[])</CODE>.

        <P><CODE>add_vertex/1</CODE> creates a vertex using the empty list
         as label, and returns the created vertex. Tuples on the form
         <CODE>['$v'&#160;|&#160;N]</CODE>, where N is an
         integer&#160;&#62;=&#160;1, are used for representing the
         created vertices.

</UL>
<P><A NAME="del_edge%2"><STRONG><CODE>del_edge(G, E) -&#62; true</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>E = edge()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes the edge <CODE>E</CODE> from the digraph <CODE>G</CODE>.

</UL>
<P><A NAME="del_edges%2"><STRONG><CODE>del_edges(G, Edges) -&#62; true</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>Edges = [edge()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes the edges in the list <CODE>Edges</CODE> from the digraph
         <CODE>G</CODE>.

</UL>
<P><A NAME="del_path%3"><STRONG><CODE>del_path(G, V1, V2) -&#62; true</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes edges from the digraph <CODE>G</CODE> until there are no
         <A HREF="#path">paths</A> from the vertex
         <CODE>V1</CODE> to the vertex <CODE>V2</CODE>.

        <P>A sketch of the procedure employed: Find an arbitrary
         <A HREF="#simple_path">simple path</A>
         v[1],&#160;v[2],&#160;...,&#160;v[k] from <CODE>V1</CODE> to
         <CODE>V2</CODE> in <CODE>G</CODE>. Remove all edges of <CODE>G</CODE> <A HREF="#emanate">emanating</A> from v[i] and <A HREF="#incident">incident</A> to v[i+1] for
         1&#160;&#60;=&#160;i&#160;&#60;&#160;k (including multiple
         edges). Repeat until there is no path between <CODE>V1</CODE> and
         <CODE>V2</CODE>.

</UL>
<P><A NAME="del_vertex%2"><STRONG><CODE>del_vertex(G, V) -&#62; true</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes the vertex <CODE>V</CODE> from the digraph <CODE>G</CODE>. Any
         edges <A HREF="#emanate">emanating</A> from
         <CODE>V</CODE> or <A HREF="#incident">incident</A>
         on <CODE>V</CODE> are also deleted.

</UL>
<P><A NAME="del_vertices%2"><STRONG><CODE>del_vertices(G, Vertices) -&#62; true</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes the vertices in the list <CODE>Vertices</CODE> from the
         digraph <CODE>G</CODE>.

</UL>
<P><A NAME="delete%1"><STRONG><CODE>delete(G) -&#62; true</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes the digraph <CODE>G</CODE>. This call is important
         because digraphs are implemented with <CODE>Ets</CODE>. There is
         no garbage collection of <CODE>Ets</CODE> tables. The digraph
         will, however, be deleted if the process that created the
         digraph terminates.

</UL>
<P><A NAME="edge%2"><STRONG><CODE>edge(G, E) -&#62; {E, V1, V2, Label} | false</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>E = edge()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Label = label()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns <CODE>{E,&#160;V1,&#160;V2,&#160;Label}</CODE> where
         <CODE>Label</CODE> is the <A HREF="#label">label</A>
         of the edge <CODE>E</CODE> <A HREF="#emanate">emanating</A> from <CODE>V1</CODE> and
         <A HREF="#incident">incident</A> on <CODE>V2</CODE>
         of the digraph <CODE>G</CODE>. If there is no edge <CODE>E</CODE> of the
         digraph <CODE>G</CODE>, then <CODE>false</CODE> is returned.

</UL>
<P><A NAME="edges%1"><STRONG><CODE>edges(G) -&#62; Edges</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>Edges = [edge()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all edges of the digraph <CODE>G</CODE>, in
         some unspecified order.

</UL>
<P><A NAME="edges%2"><STRONG><CODE>edges(G, V) -&#62; Edges</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Edges = [edge()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all edges <A HREF="#emanate">emanating</A> from or <A HREF="#incident">incident</A> on <CODE>V</CODE> of the
         digraph <CODE>G</CODE>, in some unspecified order.

</UL>
<P><A NAME="get_cycle%2"><STRONG><CODE>get_cycle(G, V) -&#62; Vertices | false</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>If there is a <A HREF="#simple_cycle">simple
         cycle</A> of length two or more through the vertex
         <CODE>V</CODE>, then the cycle is returned as a list
         <CODE>[V,&#160;...,&#160;V]</CODE> of vertices, otherwise if there
         is a <A HREF="#loop">loop</A> through
         <CODE>V</CODE>, then the loop is returned as a list <CODE>[V]</CODE>. If
         there are no cycles through <CODE>V</CODE>, then <CODE>false</CODE> is
         returned.

        <P><CODE>get_path/3</CODE> is used for finding a simple cycle
         through <CODE>V</CODE>.

</UL>
<P><A NAME="get_path%3"><STRONG><CODE>get_path(G, V1, V2) -&#62; Vertices | false</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Tries to find a <A HREF="#simple_path">simple
         path</A> from the vertex <CODE>V1</CODE> to the vertex
         <CODE>V2</CODE> of the digraph <CODE>G</CODE>. Returns the path as a
         list <CODE>[V1,&#160;...,&#160;V2]</CODE> of vertices, or
         <CODE>false</CODE> if no simple path from <CODE>V1</CODE> to <CODE>V2</CODE>
         of length one or more exists.

        <P>The digraph <CODE>G</CODE> is traversed in a depth-first manner,
         and the first path found is returned.

</UL>
<P><A NAME="get_short_cycle%2"><STRONG><CODE>get_short_cycle(G, V) -&#62; Vertices | false</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Tries to find an as short as possible <A HREF="#simple_cycle">simple cycle</A> through the
         vertex <CODE>V</CODE> of the digraph <CODE>G</CODE>. Returns the cycle
         as a list <CODE>[V,&#160;...,&#160;V]</CODE> of vertices, or
         <CODE>false</CODE> if no simple cycle through <CODE>V</CODE> exists.
         Note that a <A HREF="#loop">loop</A> through
         <CODE>V</CODE> is returned as the list <CODE>[V,&#160;V]</CODE>.

        <P><CODE>get_short_path/3</CODE> is used for finding a simple cycle
         through <CODE>V</CODE>.

</UL>
<P><A NAME="get_short_path%3"><STRONG><CODE>get_short_path(G, V1, V2) -&#62; Vertices | false</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V1 = V2 = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Tries to find an as short as possible <A HREF="#simple_path">simple path</A> from the vertex
         <CODE>V1</CODE> to the vertex <CODE>V2</CODE> of the digraph <CODE>G</CODE>.
         Returns the path as a list <CODE>[V1,&#160;...,&#160;V2]</CODE> of
         vertices, or <CODE>false</CODE> if no simple path from <CODE>V1</CODE>
         to <CODE>V2</CODE> of length one or more exists.

        <P>The digraph <CODE>G</CODE> is traversed in a breadth-first
         manner, and the first path found is returned.

</UL>
<P><A NAME="in_degree%2"><STRONG><CODE>in_degree(G, V) -&#62; integer()</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G= digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns the <A HREF="#in_degree">in-degree</A> of the vertex
         <CODE>V</CODE> of the digraph <CODE>G</CODE>.

</UL>
<P><A NAME="in_edges%2"><STRONG><CODE>in_edges(G, V) -&#62; Edges</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Edges = [edge()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all edges <A HREF="#incident">incident</A> on <CODE>V</CODE> of the
         digraph <CODE>G</CODE>, in some unspecified order.

</UL>
<P><A NAME="in_neighbours%2"><STRONG><CODE>in_neighbours(G, V) -&#62; Vertices</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all <A HREF="#in_neighbour">in-neighbours</A> of <CODE>V</CODE>
         of the digraph <CODE>G</CODE>, in some unspecified order.

</UL>
<P><A NAME="info%1"><STRONG><CODE>info(G) -&#62; InfoList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>InfoList = [{cyclicity, Cyclicity}, {memory, NoWords},
         {protection, Protection}]</CODE></STRONG><BR>
<STRONG><CODE>Cyclicity = cyclic | acyclic</CODE></STRONG><BR>
<STRONG><CODE>Protection = public | protected | private</CODE></STRONG><BR>
<STRONG><CODE>NoWords = integer() &#62;= 0</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of <CODE>{Tag, Value}</CODE> pairs describing the
         digraph <CODE>G</CODE>. The following pairs are returned:

        <P><UL>
<LI><CODE>{cyclicity, Cyclicity}</CODE>, where <CODE>Cyclicity</CODE>
         is <CODE>cyclic</CODE> or <CODE>acyclic</CODE>, according to the
         options given to <CODE>new</CODE>.
         <BR>
</LI><BR>
<LI><CODE>{memory, NoWords}</CODE>, where <CODE>NoWords</CODE> is 
         the number of words allocated to the <CODE>ets</CODE> tables.
         <BR>
</LI><BR>
<LI><CODE>{protection, Protection}</CODE>, where <CODE>Protection</CODE>
         is <CODE>public</CODE>, <CODE>protected</CODE> or <CODE>private</CODE>, according
         to the options given to <CODE>new</CODE>.
        <BR>
</LI><BR>
</UL>
</UL>
<P><A NAME="new%0"><STRONG><CODE>new() -&#62; digraph()</CODE></STRONG></A><BR>
<UL>
<P>Equivalent to <CODE>new([])</CODE>.

</UL>
<P><A NAME="new%1"><STRONG><CODE>new(Type) -&#62; digraph() | {error, Reason}</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Type = [cyclic | acyclic | public | private | protected]</CODE></STRONG><BR>
<STRONG><CODE>Reason = {unknown_type, term()}</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns an <A HREF="#empty_digraph">empty
         digraph</A> with properties according to the options
         in <CODE>Type</CODE>:
        <P><DL>
<DT><CODE>cyclic</CODE>
         </DT>
<DD>Allow <A HREF="#cycle">cycles</A> in the
         digraph (default).
         </DD>
<DT><CODE>acyclic</CODE>
         </DT>
<DD>The digraph is to be kept <A HREF="#acyclic_digraph">acyclic</A>.
         </DD>
<DT><CODE>public</CODE>
         </DT>
<DD>The digraph may be read and modified by any process.
         </DD>
<DT><CODE>protected</CODE>
         </DT>
<DD>Other processes can only read the digraph (default).
         </DD>
<DT><CODE>private</CODE>
         </DT>
<DD>The digraph can be read and modified by the creating
         process only.
        </DD>
</DL>
<P>If an unrecognized type option T is given, then
         <CODE>{error,&#160;{unknown_type,&#160;</CODE>T<CODE>}}</CODE> is
         returned.

</UL>
<P><A NAME="no_edges%1"><STRONG><CODE>no_edges(G) -&#62; integer() &#62;= 0</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns the number of edges of the digraph <CODE>G</CODE>.

</UL>
<P><A NAME="no_vertices%1"><STRONG><CODE>no_vertices(G) -&#62; integer() &#62;= 0</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns the number of vertices of the digraph <CODE>G</CODE>.

</UL>
<P><A NAME="out_degree%2"><STRONG><CODE>out_degree(G, V) -&#62; integer()</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns the <A HREF="#out_degree">out-degree</A> of the vertex
         <CODE>V</CODE> of the digraph <CODE>G</CODE>.

</UL>
<P><A NAME="out_edges%2"><STRONG><CODE>out_edges(G, V) -&#62; Edges</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Edges = [edge()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all edges <A HREF="#emanate">emanating</A> from <CODE>V</CODE> of the
         digraph <CODE>G</CODE>, in some unspecified order.

</UL>
<P><A NAME="out_neighbours%2"><STRONG><CODE>out_neighbours(G, V) -&#62; Vertices</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all <A HREF="#out_neighbour">out-neighbours</A> of <CODE>V</CODE>
         of the digraph <CODE>G</CODE>, in some unspecified order.

</UL>
<P><A NAME="vertex%2"><STRONG><CODE>vertex(G, V) -&#62; {V, Label} | false</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>V = vertex()</CODE></STRONG><BR>
<STRONG><CODE>Label = label()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns <CODE>{V,&#160;Label}</CODE> where <CODE>Label</CODE> is the
         <A HREF="#label">label</A> of the vertex
         <CODE>V</CODE> of the digraph <CODE>G</CODE>, or <CODE>false</CODE> if there
         is no vertex <CODE>V</CODE> of the digraph <CODE>G</CODE>.

</UL>
<P><A NAME="vertices%1"><STRONG><CODE>vertices(G) -&#62; Vertices</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>G = digraph()</CODE></STRONG><BR>
<STRONG><CODE>Vertices = [vertex()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of all vertices of the digraph <CODE>G</CODE>, in
         some unspecified order.

</UL>
<H3>See Also</H3>
<UL>
<P><A HREF="digraph_utils.html">digraph_utils</A>(3), ets(3)

</UL>
<H3>AUTHORS</H3>
<UL>
Tony Rogvall - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright &copy; 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>