|
Initializes a graph.
Reads a description of a graph from an input file and creates it. Allocates an array if nodes, and adds arcs as necessary. -
Parameters:
-
graph |
the output graph |
file_name |
the name of the input file that contains the graph description. |
The file format follows. The number of nodes in the graph (must be greater than 0) followed by bi-directional arcs. An id of a node is a number from 0 to n-1. Each arc is described by a pair of nodes embeded within parenthesis and separated with a comma, for example (1, 2)
-
Returns:
-
0 upon success, and a negative number upon failure.
Possible errors: 1. The input file does not exist or it is not readable 2. The number of nodes is 0 3. An attempt to insert an arc that already exists. For example (a,b), (b,a) 4. An attempt to insert a self loops (a, a) |