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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

sage: gbe.add_vertices(verts)<br />

sage: gbe.delete_vertex("A")<br />

sage: gbe.vertices()<br />

[’D’]<br />

sage: gbe.delete_vertex("A")<br />

Traceback (most recent call last):<br />

...<br />

RuntimeError: Vertex A does not exist.<br />

delete_vertices(verts)<br />

Removes vertices from the graph.<br />

Trying to delete a non existing vertex will raise an exception.<br />

INPUT:<br />

•verts – iterable container containing names (as str) of the vertices to delete<br />

EXAMPLE:<br />

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

sage: gbe = GLPKGraphBackend()<br />

sage: verts = ["A", "B", "C", "D"]<br />

sage: gbe.add_vertices(verts)<br />

sage: v_d = ["A", "B"]<br />

sage: gbe.delete_vertices(v_d)<br />

sage: gbe.vertices()<br />

[’C’, ’D’]<br />

sage: gbe.delete_vertices(["C", "A"])<br />

Traceback (most recent call last):<br />

...<br />

RuntimeError: Vertex A does not exist.<br />

sage: gbe.vertices()<br />

[’C’, ’D’]<br />

edges()<br />

Returns a list of all edges in the graph<br />

OUTPUT:<br />

A list of triples representing the edges of the graph.<br />

EXAMPLE:<br />

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

sage: gbe = GLPKGraphBackend()<br />

sage: edges = [("A", "B", {"low":0.0, "cap":10.0, "cost":5})]<br />

sage: edges.append(("B", "C"))<br />

sage: gbe.add_edges(edges)<br />

sage: for ed in gbe.edges():<br />

... print ed[0], ed[1], ed[2][’cost’]<br />

A B 5.0<br />

B C 0.0<br />

get_edge(u, v)<br />

Returns an edge connecting two vertices.<br />

Note: If multiple edges connect the two vertices only the first edge found is returned.<br />

INPUT:<br />

86 Chapter 5. LP Solver backends

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

Saved successfully!

Ooh no, something went wrong!