09.02.2015 Views

Sage Reference Manual: Numerical Optimization - Mirrors

Sage Reference Manual: Numerical Optimization - Mirrors

Sage Reference Manual: Numerical Optimization - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Numerical</strong> <strong>Optimization</strong>, Release 6.1.1<br />

5.3.2 Classes and methods<br />

class sage.numerical.backends.glpk_graph_backend.GLPKGraphBackend<br />

Bases: object<br />

GLPK Backend for access to GLPK graph functions<br />

The constructor can either be called without arguments (which results in an empty graph) or with arguments to<br />

read graph data from a file.<br />

INPUT:<br />

•data – a filename or a Graph object.<br />

•format – when data is a filename, specifies the format of the data read from a file. The format<br />

parameter is a string and can take values as described in the table below.<br />

Format parameters:<br />

plain<br />

Read data from a plain text file containing the following<br />

information:<br />

nv na<br />

i[1] j[1]<br />

i[2] j[2]<br />

. . .<br />

i[na] j[na]<br />

where:<br />

•nv is the number of vertices (nodes);<br />

•na is the number of arcs;<br />

•i[k], k = 1, . . . , na, is the index of tail vertex<br />

of arc k;<br />

•j[k], k = 1, . . . , na, is the index of head vertex<br />

of arc k.<br />

dimacs<br />

mincost<br />

maxflow<br />

Read data from a plain ASCII text file in DIMACS<br />

format. A discription of the DIMACS format can be<br />

found at http://dimacs.rutgers.edu/Challenges/.<br />

Reads the mincost flow problem data from a text file<br />

in DIMACS format<br />

Reads the maximum flow problem data from a text<br />

file in DIMACS format<br />

Note: When data is a Graph, the following restrictions are applied.<br />

•vertices – the value of the demand of each vertex (see set_vertex_demand()) is obtained from the<br />

numerical value associated with the key “rhs” if it is a dictionary.<br />

•edges – The edge values used in the algorithms are read from the edges labels (and left undefined if the<br />

edge labels are equal to None). To be defined, the labels must be dict objects with keys “low”, “cap”<br />

and “cost”. See get_edge() for details.<br />

EXAMPLES:<br />

The following example creates an empty graph:<br />

sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend<br />

sage: gbe = GLPKGraphBackend()<br />

5.3. GLPK Backend for access to GLPK graph functions 81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!