Ticket #9269: trac_9269.patch

File trac_9269.patch, 37.6 KB (added by rlm, 3 years ago)
  • sage/graphs/digraph.py

    # HG changeset patch
    # User Robert L. Miller <rlm@rlmiller.org>
    # Date 1276901396 25200
    # Node ID 49971fc086c87861b671d58ebfe396a5f9bc865d
    # Parent  556bb66e4c6dbb92a4ee37c1750d82a5c6298eeb
    #9269: Better use of #optional in sage/graphs
    
    diff -r 556bb66e4c6d -r 49971fc086c8 sage/graphs/digraph.py
    a b  
    11641164            sage: dcycle=DiGraph(cycle) 
    11651165            sage: cycle.size()  
    11661166            5 
    1167             sage: dcycle.feedback_edge_set(value_only=True)    # optional - requires GLPK or CBC 
     1167            sage: dcycle.feedback_edge_set(value_only=True)    # optional - GLPK, CBC 
    11681168            5.0 
    11691169         
    11701170        And in this situation, for any edge `uv` of the first graph, `uv` of `vu` 
     
    11721172 
    11731173           sage: g = graphs.RandomGNP(5,.3) 
    11741174           sage: dg = DiGraph(g) 
    1175            sage: feedback = dg.feedback_edge_set()             # optional - requires GLPK or CBC 
     1175           sage: feedback = dg.feedback_edge_set()             # optional - GLPK, CBC 
    11761176           sage: (u,v,l) = g.edge_iterator().next() 
    1177            sage: (u,v) in feedback or (v,u) in feedback        # optional - requires GLPK or CBC 
     1177           sage: (u,v) in feedback or (v,u) in feedback        # optional - GLPK, CBC 
    11781178           True 
    11791179        """ 
    11801180         
     
    12841284 
    12851285            sage: cycle=graphs.CycleGraph(5) 
    12861286            sage: dcycle=DiGraph(cycle) 
    1287             sage: cycle.vertex_cover(value_only=True)         # optional - requires GLPK or CBC 
     1287            sage: cycle.vertex_cover(value_only=True)         # optional - GLPK, CBC 
    12881288            3 
    1289             sage: feedback = dcycle.feedback_vertex_set()     # optional - requires GLPK or CBC 
    1290             sage: feedback.cardinality()                      # optional - requires GLPK or CBC 
     1289            sage: feedback = dcycle.feedback_vertex_set()     # optional - GLPK, CBC 
     1290            sage: feedback.cardinality()                      # optional - GLPK, CBC 
    12911291            3 
    12921292            sage: (u,v,l) = cycle.edge_iterator().next() 
    1293             sage: u in feedback or v in feedback              # optional - requires GLPK or CBC 
     1293            sage: u in feedback or v in feedback              # optional - GLPK, CBC 
    12941294            True 
    12951295             
    12961296        For a circuit, the minimum feedback arc set is clearly `1`:: 
    12971297 
    12981298            sage: circuit = digraphs.Circuit(5) 
    1299             sage: circuit.feedback_vertex_set(value_only=True) == 1    # optional - requires GLPK or CBC 
     1299            sage: circuit.feedback_vertex_set(value_only=True) == 1    # optional - GLPK, CBC 
    13001300            True 
    13011301        """ 
    13021302         
  • sage/graphs/generic_graph.py

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/graphs/generic_graph.py
    a b  
    20662066        Given a complete bipartite graph `K_{n,m}`, the maximum out-degree 
    20672067        of an optimal orientation is `\left\lceil \frac {nm} {n+m}\right\rceil`:: 
    20682068 
    2069             sage: g = graphs.CompleteBipartiteGraph(3,4) 
    2070             sage: o = g.minimum_outdegree_orientation() # optional - requires GLPK or CBC 
    2071             sage: max(o.out_degree()) == ceil((4*3)/(3+4)) # optional - requires GLPK or CBC 
     2069            sage: g = graphs.CompleteBipartiteGraph(3,4)   # optional - GLPK, CBC 
     2070            sage: o = g.minimum_outdegree_orientation()    # optional - GLPK, CBC 
     2071            sage: max(o.out_degree()) == ceil((4*3)/(3+4)) # optional - GLPK, CBC 
    20722072            True 
    20732073 
    20742074        REFERENCES: 
     
    31393139        A basic application in the Pappus graph:: 
    31403140         
    31413141           sage: g = graphs.PappusGraph() 
    3142            sage: g.edge_cut(1, 2, value_only=True) # optional - requires GLPK or COIN-OR/CBC 
     3142           sage: g.edge_cut(1, 2, value_only=True) # optional - GLPK, CBC 
    31433143           3.0 
    31443144 
    31453145        If the graph is a path with randomly weighted edges:: 
     
    31513151        The edge cut between the two ends is the edge of minimum weight:: 
    31523152 
    31533153           sage: minimum = min([l for u,v,l in g.edge_iterator()]) 
    3154            sage: abs(minimum - g.edge_cut(0, 14, use_edge_labels=True)) < 10**(-5) # optional - requires GLPK or COIN-OR/CBC or CPLEX 
    3155            True 
    3156            sage: [value,[[u,v]]] = g.edge_cut(0, 14, use_edge_labels=True, value_only=False) # optional - requires GLPK or COIN-OR/CBC 
    3157            sage: g.edge_label(u, v) == minimum # optional - requires GLPK or COIN-OR/CBC 
     3154           sage: abs(minimum - g.edge_cut(0, 14, use_edge_labels=True)) < 10**(-5) # optional - GLPK, CBC 
     3155           True 
     3156           sage: [value,[[u,v]]] = g.edge_cut(0, 14, use_edge_labels=True, value_only=False) # optional - GLPK, CBC 
     3157           sage: g.edge_label(u, v) == minimum # optional - GLPK, CBC 
    31583158           True 
    31593159 
    31603160        The two sides of the edge cut are obviously shorter paths:: 
    31613161 
    3162            sage: value,edges,[set1,set2] = g.edge_cut(0, 14, use_edge_labels=True, vertices=True)  # optional - requires GLPK or COIN-OR/CBC 
    3163            sage: g.subgraph(set1).is_isomorphic(graphs.PathGraph(len(set1))) # optional - requires GLPK or COIN-OR/CBC 
    3164            True 
    3165            sage: g.subgraph(set2).is_isomorphic(graphs.PathGraph(len(set2))) # optional - requires GLPK or COIN-OR/CBC 
    3166            True 
    3167            sage: len(set1) + len(set2) == g.order() # optional - requires GLPK or COIN-OR/CBC 
     3162           sage: value,edges,[set1,set2] = g.edge_cut(0, 14, use_edge_labels=True, vertices=True)  # optional - GLPK, CBC 
     3163           sage: g.subgraph(set1).is_isomorphic(graphs.PathGraph(len(set1))) # optional - GLPK, CBC 
     3164           True 
     3165           sage: g.subgraph(set2).is_isomorphic(graphs.PathGraph(len(set2))) # optional - GLPK, CBC 
     3166           True 
     3167           sage: len(set1) + len(set2) == g.order() # optional - GLPK, CBC 
    31683168           True 
    31693169        """ 
    31703170        from sage.numerical.mip import MixedIntegerLinearProgram 
     
    32723272        A basic application in the Pappus graph:: 
    32733273         
    32743274           sage: g = graphs.PappusGraph() 
    3275            sage: g.vertex_cut(1, 16, value_only=True) # optional - requires GLPK or COIN-OR/CBC 
     3275           sage: g.vertex_cut(1, 16, value_only=True) # optional - GLPK, CBC 
    32763276           3.0 
    32773277 
    32783278        In the bipartite complete graph `K_{2,8}`, a cut between the two 
    32793279        vertices in the size `2` part consists of the other `8` vertices:: 
    32803280 
    32813281           sage: g = graphs.CompleteBipartiteGraph(2, 8) 
    3282            sage: [value, vertices] = g.vertex_cut(0, 1, value_only=False) # optional - requires GLPK or COIN-OR/CBC 
    3283            sage: print value # optional - requires GLPK or COIN-OR/CBC 
     3282           sage: [value, vertices] = g.vertex_cut(0, 1, value_only=False) # optional - GLPK, CBC 
     3283           sage: print value # optional - GLPK, CBC 
    32843284           8.0 
    3285            sage: vertices == range(2,10) # optional - requires GLPK or COIN-OR/CBC 
     3285           sage: vertices == range(2,10) # optional - GLPK, CBC 
    32863286           True 
    32873287 
    32883288        Clearly, in this case the two sides of the cut are singletons :: 
    32893289 
    3290            sage: [value, vertices, [set1, set2]] = g.vertex_cut(0,1, vertices=True) # optional - requires GLPK or COIN-OR/CBC 
    3291            sage: len(set1) == 1 # optional - requires GLPK or COIN-OR/CBC 
    3292            True 
    3293            sage: len(set2) == 1 # optional - requires GLPK or COIN-OR/CBC 
     3290           sage: [value, vertices, [set1, set2]] = g.vertex_cut(0,1, vertices=True) # optional - GLPK, CBC 
     3291           sage: len(set1) == 1 # optional - GLPK, CBC 
     3292           True 
     3293           sage: len(set2) == 1 # optional - GLPK, CBC 
    32943294           True 
    32953295        """ 
    32963296        from sage.numerical.mip import MixedIntegerLinearProgram 
     
    34203420        The two algorithms should return the same result:: 
    34213421 
    34223422           sage: g = graphs.RandomGNP(10,.5) 
    3423            sage: vc1 = g.vertex_cover(algorithm="MILP") # optional requires GLPK or CBC 
    3424            sage: vc2 = g.vertex_cover(algorithm="Cliquer") # optional requires GLPK or CBC 
    3425            sage: len(vc1) == len(vc2) # optional requires GLPK or CBC 
     3423           sage: vc1 = g.vertex_cover(algorithm="MILP") # optional - GLPK, CBC 
     3424           sage: vc2 = g.vertex_cover(algorithm="Cliquer") # optional - GLPK, CBC 
     3425           sage: len(vc1) == len(vc2) # optional - GLPK, CBC 
    34263426           True 
    34273427        """ 
    34283428        if algorithm == "Cliquer": 
     
    36503650        The Heawood graph is known to be hamiltonian:: 
    36513651 
    36523652            sage: g = graphs.HeawoodGraph() 
    3653             sage: tsp = g.traveling_salesman_problem()   # optional - requires GLPK, CBC, or CPLEX 
    3654             sage: tsp                                     # optional - requires GLPK, CBC, or CPLEX 
     3653            sage: tsp = g.traveling_salesman_problem()   # optional - GLPK, CBC 
     3654            sage: tsp                                     # optional - GLPK, CBC 
    36553655            TSP from Heawood graph: Graph on 14 vertices 
    36563656 
    36573657        The solution to the TSP has to be connected :: 
    36583658 
    3659             sage: tsp.is_connected()                      # optional - requires GLPK, CBC, or CPLEX 
     3659            sage: tsp.is_connected()                      # optional - GLPK, CBC 
    36603660            True 
    36613661 
    36623662        It must also be a `2`-regular graph:: 
    36633663 
    3664             sage: tsp.is_regular(k=2)                     # optional - requires GLPK, CBC, or CPLEX 
     3664            sage: tsp.is_regular(k=2)                     # optional - GLPK, CBC 
    36653665            True 
    36663666 
    36673667        And obviously it is a subgraph of the Heawood graph:: 
    36683668 
    3669             sage: all([ e in g.edges() for e in tsp.edges()])    # optional - requires GLPK, CBC, or CPLEX 
     3669            sage: all([ e in g.edges() for e in tsp.edges()])    # optional - GLPK, CBC 
    36703670            True 
    36713671 
    36723672        On the other hand, the Petersen Graph is known not to 
    36733673        be hamiltonian:: 
    36743674 
    3675             sage: g = graphs.PetersenGraph()                     # optional - requires GLPK, CBC, or CPLEX 
    3676             sage: tsp = g.traveling_salesman_problem()          # optional - requires GLPK, CBC, or CPLEX 
     3675            sage: g = graphs.PetersenGraph()                     # optional - GLPK, CBC 
     3676            sage: tsp = g.traveling_salesman_problem()          # optional - GLPK, CBC 
    36773677            Traceback (most recent call last): 
    36783678            ... 
    36793679            ValueError: The given graph is not hamiltonian 
     
    36953695            ...          g.add_edge(u,v) 
    36963696            ...      g.set_edge_label(u,v,2) 
    36973697 
    3698             sage: tsp = g.traveling_salesman_problem(weighted = True)   # optional - requires GLPK, CBC, or CPLEX 
    3699             sage: sum( tsp.edge_labels() ) < 2*10                       # optional - requires GLPK, CBC, or CPLEX 
     3698            sage: tsp = g.traveling_salesman_problem(weighted = True)   # optional - GLPK, CBC 
     3699            sage: sum( tsp.edge_labels() ) < 2*10                       # optional - GLPK, CBC 
    37003700            True 
    37013701 
    37023702        If we pick `1/2` instead of `2` as a cost for these new edges, 
     
    37053705            sage: for u,v in cycle.edges(labels = None): 
    37063706            ...      g.set_edge_label(u,v,1/2) 
    37073707 
    3708             sage: tsp = g.traveling_salesman_problem(weighted = True)   # optional - requires GLPK, CBC, or CPLEX 
    3709             sage: sum( tsp.edge_labels() ) == (1/2)*10                   # optional - requires GLPK, CBC, or CPLEX 
     3708            sage: tsp = g.traveling_salesman_problem(weighted = True)   # optional - GLPK, CBC 
     3709            sage: sum( tsp.edge_labels() ) == (1/2)*10                   # optional - GLPK, CBC 
    37103710            True 
    37113711 
    37123712        """ 
     
    38653865        The Heawood Graph is known to be hamiltonian :: 
    38663866 
    38673867            sage: g = graphs.HeawoodGraph() 
    3868             sage: g.hamiltonian_cycle()         # optional - requires GLPK, CBC, or CPLEX 
     3868            sage: g.hamiltonian_cycle()         # optional - GLPK, CBC 
    38693869            TSP from Heawood graph: Graph on 14 vertices 
    38703870 
    38713871        The Petergraph, though, is not :: 
    38723872 
    38733873            sage: g = graphs.PetersenGraph() 
    3874             sage: g.hamiltonian_cycle()         # optional - requires GLPK, CBC, or CPLEX 
     3874            sage: g.hamiltonian_cycle()         # optional - GLPK, CBC 
    38753875            Traceback (most recent call last): 
    38763876            ... 
    38773877            ValueError: The given graph is not hamiltonian 
     
    39673967            sage: g.add_edges([('s',i) for i in range(4)])  
    39683968            sage: g.add_edges([(i,4+j) for i in range(4) for j in range(4)]) 
    39693969            sage: g.add_edges([(4+i,'t') for i in range(4)]) 
    3970             sage: [cardinal, flow_graph] = g.flow('s','t',integer=True,value_only=False) # optional - requires GLPK or CBC 
    3971             sage: flow_graph.delete_vertices(['s','t'])                                  # optional - requires GLPK or CBC 
    3972             sage: len(flow_graph.edges(labels=None))                                     # optional - requires GLPK or CBC    
     3970            sage: [cardinal, flow_graph] = g.flow('s','t',integer=True,value_only=False) # optional - GLPK, CBC 
     3971            sage: flow_graph.delete_vertices(['s','t'])                                  # optional - GLPK, CBC 
     3972            sage: len(flow_graph.edges(labels=None))                                     # optional - GLPK, CBC    
    39733973            4 
    39743974         
    39753975        """ 
     
    40974097        In a complete bipartite graph :: 
    40984098 
    40994099            sage: g = graphs.CompleteBipartiteGraph(2,3) 
    4100             sage: g.edge_disjoint_paths(0,1) # optional - requires GLPK or CBC 
     4100            sage: g.edge_disjoint_paths(0,1) # optional - GLPK, CBC 
    41014101            [[0, 2, 1], [0, 3, 1], [0, 4, 1]] 
    41024102        """ 
    41034103 
     
    41374137        In a complete bipartite graph :: 
    41384138 
    41394139            sage: g = graphs.CompleteBipartiteGraph(2,3) 
    4140             sage: g.vertex_disjoint_paths(0,1) # optional - requires GLPK or CBC 
     4140            sage: g.vertex_disjoint_paths(0,1) # optional - GLPK, CBC 
    41414141            [[0, 2, 1], [0, 3, 1], [0, 4, 1]] 
    41424142        """ 
    41434143 
     
    42234223        Same test with the Linear Program formulation:: 
    42244224 
    42254225           sage: g = graphs.PappusGraph() 
    4226            sage: g.matching(algorithm="LP", value_only=True) #optional - requires GLPK CBC or CPLEX 
     4226           sage: g.matching(algorithm="LP", value_only=True) # optional - GLPK, CBC 
    42274227           9.0 
    42284228 
    42294229        TESTS: 
     
    62706270        degree:: 
    62716271 
    62726272            sage: g = graphs.RandomGNP(20,.3) 
    6273             sage: mad_g = g.maximum_average_degree()                       # optional - requires GLPK or CBC 
    6274             sage: g.average_degree() <= mad_g                              # optional - requires GLPK or CBC 
     6273            sage: mad_g = g.maximum_average_degree()                       # optional - GLPK, CBC 
     6274            sage: g.average_degree() <= mad_g                              # optional - GLPK, CBC 
    62756275            True 
    62766276 
    62776277        Unlike the average degree, the `Mad` of the disjoint 
     
    62796279        graphs:: 
    62806280 
    62816281            sage: h = graphs.RandomGNP(20,.3) 
    6282             sage: mad_h = h.maximum_average_degree()                      # optional - requires GLPK or CBC 
    6283             sage: (g+h).maximum_average_degree() == max(mad_g, mad_h)     # optional - requires GLPK or CBC 
     6282            sage: mad_h = h.maximum_average_degree()                      # optional - GLPK, CBC 
     6283            sage: (g+h).maximum_average_degree() == max(mad_g, mad_h)     # optional - GLPK, CBC 
    62846284            True 
    62856285 
    62866286        The subgraph of a regular graph realizing the maximum 
    62876287        average degree is always the whole graph :: 
    62886288 
    62896289            sage: g = graphs.CompleteGraph(5) 
    6290             sage: mad_g = g.maximum_average_degree(value_only=False)      # optional - requires GLPK or CBC 
    6291             sage: g.is_isomorphic(mad_g)                                  # optional - requires GLPK or CBC 
     6290            sage: mad_g = g.maximum_average_degree(value_only=False)      # optional - GLPK, CBC 
     6291            sage: g.is_isomorphic(mad_g)                                  # optional - GLPK, CBC 
    62926292            True 
    62936293 
    62946294        This also works for complete bipartite graphs :: 
    62956295 
    6296             sage: g = graphs.CompleteBipartiteGraph(3,4)                  # optional - requires GLPK or CBC 
    6297             sage: mad_g = g.maximum_average_degree(value_only=False)      # optional - requires GLPK or CBC 
    6298             sage: g.is_isomorphic(mad_g)                                  # optional - requires GLPK or CBC 
     6296            sage: g = graphs.CompleteBipartiteGraph(3,4)                  # optional - GLPK, CBC 
     6297            sage: mad_g = g.maximum_average_degree(value_only=False)      # optional - GLPK, CBC 
     6298            sage: g.is_isomorphic(mad_g)                                  # optional - GLPK, CBC 
    62996299            True            
    63006300        """ 
    63016301 
     
    1196511965        The Heawood Graph is known to be hamiltonian :: 
    1196611966 
    1196711967            sage: g = graphs.HeawoodGraph() 
    11968             sage: g.is_hamiltonian()         # optional - requires GLPK, CBC, or CPLEX 
     11968            sage: g.is_hamiltonian()         # optional - GLPK, CBC 
    1196911969            True 
    1197011970 
    1197111971        The Petergraph, though, is not :: 
    1197211972 
    1197311973            sage: g = graphs.PetersenGraph() 
    11974             sage: g.is_hamiltonian()         # optional - requires GLPK, CBC, or CPLEX 
     11974            sage: g.is_hamiltonian()         # optional - GLPK, CBC 
    1197511975            False 
    1197611976 
    1197711977        """ 
  • sage/graphs/graph.py

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/graphs/graph.py
    a b  
    14451445 
    14461446            sage: g = graphs.CycleGraph(6) 
    14471447            sage: bounds = lambda x: [1,1] 
    1448             sage: m = g.degree_constrained_subgraph(bounds=bounds) # optional - requires GLPK or CBC or CPLEX 
    1449             sage: m.size() # optional - requires GLPK or CBC or CPLEX 
     1448            sage: m = g.degree_constrained_subgraph(bounds=bounds) # optional - GLPK, CBC 
     1449            sage: m.size() # optional - GLPK, CBC 
    14501450            3 
    14511451        """ 
    14521452 
     
    17241724            sage: G = Graph({0: [1, 2, 3], 1: [2]}) 
    17251725            sage: G.chromatic_number(algorithm="DLX") 
    17261726            3 
    1727             sage: G.chromatic_number(algorithm="MILP") # optional - requires GLPK or CBC 
     1727            sage: G.chromatic_number(algorithm="MILP") # optional - GLPK, CBC 
    17281728            3 
    17291729            sage: G.chromatic_number(algorithm="CP") 
    17301730            3 
     
    17831783        EXAMPLES:: 
    17841784         
    17851785            sage: G = Graph("Fooba") 
    1786             sage: P = G.coloring(algorithm="MILP"); P  # optional - requires GLPK or CBC 
     1786            sage: P = G.coloring(algorithm="MILP"); P  # optional - GLPK, CBC 
    17871787            [[2, 1, 3], [0, 6, 5], [4]] 
    17881788            sage: P = G.coloring(algorithm="DLX"); P 
    17891789            [[1, 2, 3], [0, 5, 6], [4]] 
    17901790            sage: G.plot(partition=P) 
    1791             sage: H = G.coloring(hex_colors=True, algorithm="MILP") # optional - requires GLPK or CBC 
    1792             sage: for c in sorted(H.keys()):                        # optional - requires GLPK or CBC 
    1793             ...       print c, H[c]                                 # optional - requires GLPK or CBC 
     1791            sage: H = G.coloring(hex_colors=True, algorithm="MILP") # optional - GLPK, CBC 
     1792            sage: for c in sorted(H.keys()):                        # optional - GLPK, CBC 
     1793            ...       print c, H[c]                                 # optional - GLPK, CBC 
    17941794            #0000ff [4] 
    17951795            #00ff00 [0, 6, 5] 
    17961796            #ff0000 [2, 1, 3] 
     
    18601860         
    18611861           sage: g = graphs.CompleteBipartiteGraph(3,3) 
    18621862           sage: g.delete_edge(1,4) 
    1863            sage: g.independent_set_of_representatives([[0,1,2],[3,4,5]]) # optional - requires GLPK or CBC 
     1863           sage: g.independent_set_of_representatives([[0,1,2],[3,4,5]]) # optional - GLPK, CBC 
    18641864           [1, 4] 
    18651865 
    18661866        The Petersen Graph is 3-colorable, which can be expressed as an 
     
    18731873            sage: g = 3 * graphs.PetersenGraph() 
    18741874            sage: n = g.order()/3 
    18751875            sage: f = [[i,i+n,i+2*n] for i in xrange(n)] 
    1876             sage: isr = g.independent_set_of_representatives(f)   # optional - requires GLPK or CBC 
    1877             sage: c = [floor(i/n) for i in isr]                   # optional - requires GLPK or CBC 
    1878             sage: color_classes = [[],[],[]]                      # optional - requires GLPK or CBC 
    1879             sage: for v,i in enumerate(c):                        # optional - requires GLPK or CBC 
    1880             ...     color_classes[i].append(v)                    # optional - requires GLPK or CBC 
    1881             sage: for classs in color_classes:                    # optional - requires GLPK or CBC 
    1882             ...     g.subgraph(classs).size() == 0                # optional - requires GLPK or CBC 
     1876            sage: isr = g.independent_set_of_representatives(f)   # optional - GLPK, CBC 
     1877            sage: c = [floor(i/n) for i in isr]                   # optional - GLPK, CBC 
     1878            sage: color_classes = [[],[],[]]                      # optional - GLPK, CBC 
     1879            sage: for v,i in enumerate(c):                        # optional - GLPK, CBC 
     1880            ...     color_classes[i].append(v)                    # optional - GLPK, CBC 
     1881            sage: for classs in color_classes:                    # optional - GLPK, CBC 
     1882            ...     g.subgraph(classs).size() == 0                # optional - GLPK, CBC 
    18831883            True 
    18841884            True 
    18851885            True 
     
    20042004         
    20052005            sage: g = graphs.GridGraph([4,4]) 
    20062006            sage: h = graphs.CompleteGraph(4) 
    2007             sage: L = g.minor(h)                                                 # optional - requires GLPK, CPLEX or CBC 
    2008             sage: gg = g.subgraph(flatten(L.values(), max_level = 1))            # optional - requires GLPK, CPLEX or CBC 
    2009             sage: _ = [gg.merge_vertices(l) for l in L.values() if len(l)>1]     # optional - requires GLPK, CPLEX or CBC 
    2010             sage: gg.is_isomorphic(h)                                            # optional - requires GLPK, CPLEX or CBC 
     2007            sage: L = g.minor(h)                                                 # optional - GLPK, CBC 
     2008            sage: gg = g.subgraph(flatten(L.values(), max_level = 1))            # optional - GLPK, CBC 
     2009            sage: _ = [gg.merge_vertices(l) for l in L.values() if len(l)>1]     # optional - GLPK, CBC 
     2010            sage: gg.is_isomorphic(h)                                            # optional - GLPK, CBC 
    20112011            True 
    20122012 
    20132013        We can also try to prove this way that the Petersen graph  
    20142014        is not planar, as it has a `K_5` minor:: 
    20152015 
    20162016            sage: g = graphs.PetersenGraph() 
    2017             sage: K5_minor = g.minor(graphs.CompleteGraph(5))                    # optional long - requires GLPK, CPLEX or CBC 
     2017            sage: K5_minor = g.minor(graphs.CompleteGraph(5))                    # long, optional - GLPK, CBC 
    20182018 
    20192019        And even a `K_{3,3}` minor:: 
    20202020 
    2021             sage: K33_minor = g.minor(graphs.CompleteBipartiteGraph(3,3))        # optional long - requires GLPK, CPLEX or CBC 
     2021            sage: K33_minor = g.minor(graphs.CompleteBipartiteGraph(3,3))        # long, optional - GLPK, CBC 
    20222022             
    20232023        (It is much faster to use the linear-time test of  
    20242024        planarity in this situation, though.) 
     
    20302030            sage: g = g.subgraph(edges = g.min_spanning_tree()) 
    20312031            sage: g.is_tree() 
    20322032            True 
    2033             sage: L = g.minor(graphs.CompleteGraph(3))                           # optional - requires GLPK, CPLEX or CBC 
     2033            sage: L = g.minor(graphs.CompleteGraph(3))                           # optional - GLPK, CBC 
    20342034            Traceback (most recent call last): 
    20352035            ... 
    20362036            ValueError: This graph has no minor isomorphic to H ! 
     
    29422942        example is only present to have a doctest coverage of 100%. 
    29432943 
    29442944            sage: g = graphs.PetersenGraph() 
    2945             sage: t = g._gomory_hu_tree()      # optional - requires GLPK or CBC 
     2945            sage: t = g._gomory_hu_tree()      # optional - GLPK, CBC 
    29462946        """ 
    29472947        from sage.sets.set import Set 
    29482948         
     
    30613061        Taking the Petersen graph:: 
    30623062 
    30633063            sage: g = graphs.PetersenGraph() 
    3064             sage: t = g.gomory_hu_tree() # optional - requires GLPK or CBC 
     3064            sage: t = g.gomory_hu_tree() # optional - GLPK, CBC 
    30653065 
    30663066        Obviously, this graph is a tree:: 
    30673067 
    3068             sage: t.is_tree()  # optional - requires GLPK or CBC 
     3068            sage: t.is_tree()  # optional - GLPK, CBC 
    30693069            True 
    30703070 
    30713071        Note that if the original graph is not connected, then the 
    30723072        Gomory-Hu tree is in fact a forest:: 
    30733073 
    3074             sage: (2*g).gomory_hu_tree().is_forest() # optional - requires GLPK or CBC 
     3074            sage: (2*g).gomory_hu_tree().is_forest() # optional - GLPK, CBC 
    30753075            True 
    3076             sage: (2*g).gomory_hu_tree().is_connected() # optional - requires GLPK or CBC 
     3076            sage: (2*g).gomory_hu_tree().is_connected() # optional - GLPK, CBC 
    30773077            False 
    30783078 
    30793079        On the other hand, such a tree has lost nothing of the initial  
    30803080        graph connectedness:: 
    30813081 
    3082             sage: all([ t.flow(u,v) == g.flow(u,v) for u,v in Subsets( g.vertices(), 2 ) ]) # optional - requires GLPK or CBC 
     3082            sage: all([ t.flow(u,v) == g.flow(u,v) for u,v in Subsets( g.vertices(), 2 ) ]) # optional - GLPK, CBC 
    30833083            True 
    30843084 
    30853085        Just to make sure, we can check that the same is true for two vertices 
    30863086        in a random graph:: 
    30873087 
    30883088            sage: g = graphs.RandomGNP(20,.3) 
    3089             sage: t = g.gomory_hu_tree() # optional - requires GLPK or CBC 
    3090             sage: g.flow(0,1) == t.flow(0,1) # optional - requires GLPK or CBC 
     3089            sage: t = g.gomory_hu_tree() # optional - GLPK, CBC 
     3090            sage: g.flow(0,1) == t.flow(0,1) # optional - GLPK, CBC 
    30913091            True 
    30923092 
    30933093        And also the min cut:: 
    30943094 
    3095             sage: g.edge_connectivity() == min(t.edge_labels()) # optional - requires GLPK or CBC 
     3095            sage: g.edge_connectivity() == min(t.edge_labels()) # optional - GLPK, CBC 
    30963096            True 
    30973097        """ 
    30983098        return self._gomory_hu_tree() 
     
    31233123        be edge-partitionned into `2`-regular graphs:: 
    31243124     
    31253125            sage: g = graphs.CompleteGraph(7) 
    3126             sage: classes = g.two_factor_petersen()  # optional - requires GLPK or CBC 
    3127             sage: for c in classes:                  # optional - requires GLPK or CBC 
    3128             ...     gg = Graph()                     # optional - requires GLPK or CBC 
    3129             ...     gg.add_edges(c)                  # optional - requires GLPK or CBC 
    3130             ...     print max(gg.degree())<=2        # optional - requires GLPK or CBC 
     3126            sage: classes = g.two_factor_petersen()  # optional - GLPK, CBC 
     3127            sage: for c in classes:                  # optional - GLPK, CBC 
     3128            ...     gg = Graph()                     # optional - GLPK, CBC 
     3129            ...     gg.add_edges(c)                  # optional - GLPK, CBC 
     3130            ...     print max(gg.degree())<=2        # optional - GLPK, CBC 
    31313131            True 
    31323132            True 
    31333133            True 
    3134             sage: Set(set(classes[0]) | set(classes[1]) | set(classes[2])).cardinality() == g.size() # optional - requires GLPK or CBC 
     3134            sage: Set(set(classes[0]) | set(classes[1]) | set(classes[2])).cardinality() == g.size() # optional - GLPK, CBC 
    31353135            True 
    31363136 
    31373137        :: 
  • sage/graphs/graph_coloring.py

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/graphs/graph_coloring.py
    a b  
    299299 
    300300       sage: from sage.graphs.graph_coloring import vertex_coloring 
    301301       sage: g = graphs.PetersenGraph() 
    302        sage: vertex_coloring(g, value_only=True) # optional - requires GLPK or CBC 
     302       sage: vertex_coloring(g, value_only=True) # optional - GLPK, CBC 
    303303       3 
    304304    """ 
    305305    from sage.numerical.mip import MixedIntegerLinearProgram 
     
    510510 
    511511       sage: from sage.graphs.graph_coloring import edge_coloring 
    512512       sage: g = graphs.PetersenGraph() 
    513        sage: edge_coloring(g, value_only=True) # optional - requires GLPK or CBC 
     513       sage: edge_coloring(g, value_only=True) # optional - GLPK, CBC 
    514514       4 
    515515 
    516516    Complete graphs are colored using the linear-time round-robin coloring:: 
  • sage/numerical/mip.pyx

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/numerical/mip.pyx
    a b  
    4141         sage: for (u,v) in g.edges(labels=None): 
    4242         ...       p.add_constraint(b[u] + b[v], max=1) 
    4343         sage: p.set_binary(b) 
    44          sage: p.solve(objective_only=True)     # optional - requires Glpk or COIN-OR/CBC 
     44         sage: p.solve(objective_only=True)     # optional - GLPK, CBC 
    4545         4.0 
    4646    """ 
    4747     
     
    486486            sage: x = p.new_variable() 
    487487            sage: p.set_objective(x[1] + x[2]) 
    488488            sage: p.add_constraint(-3*x[1] + 2*x[2], max=2,name="OneConstraint") 
    489             sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires GLPK 
     489            sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - GLPK 
    490490 
    491491        For information about the MPS file format : 
    492492        http://en.wikipedia.org/wiki/MPS_%28format%29 
     
    518518            sage: x = p.new_variable() 
    519519            sage: p.set_objective(x[1] + x[2]) 
    520520            sage: p.add_constraint(-3*x[1] + 2*x[2], max=2) 
    521             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires GLPK 
     521            sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - GLPK 
    522522 
    523523        For more information about the LP file format : 
    524524        http://lpsolve.sourceforge.net/5.5/lp-format.htm 
     
    556556            sage: y = p.new_variable(dim=2) 
    557557            sage: p.set_objective(x[3] + 3*y[2][9] + x[5]) 
    558558            sage: p.add_constraint(x[3] + y[2][9] + 2*x[5], max=2) 
    559             sage: p.solve() # optional - requires Glpk or COIN-OR/CBC 
     559            sage: p.solve() # optional - GLPK, CBC 
    560560            6.0 
    561561             
    562562        To return  the optimal value of ``y[2][9]``:: 
    563563 
    564             sage: p.get_values(y[2][9]) # optional - requires Glpk or COIN-OR/CBC 
     564            sage: p.get_values(y[2][9]) # optional - GLPK, CBC 
    565565            2.0 
    566566 
    567567        To get a dictionary identical to ``x`` containing optimal  
     
    640640            sage: p.set_objective(x[1] + 5*x[2]) 
    641641            sage: p.add_constraint(x[1] + 2/10*x[2], max=4) 
    642642            sage: p.add_constraint(1.5*x[1]+3*x[2], max=4) 
    643             sage: round(p.solve(),5)     # optional - requires Glpk or COIN-OR/CBC 
     643            sage: round(p.solve(),5)     # optional - GLPK, CBC 
    644644            6.66667 
    645645            sage: p.set_objective(None) 
    646             sage: p.solve() #optional - requires Glpk or COIN-OR/CBC 
     646            sage: p.solve() #optional - GLPK, CBC 
    647647            0.0 
    648648        """ 
    649649 
     
    705705            sage: p.set_objective(x[1] + 5*x[2]) 
    706706            sage: p.add_constraint(x[1] + 0.2*x[2], max=4) 
    707707            sage: p.add_constraint(1.5*x[1] + 3*x[2], max=4) 
    708             sage: round(p.solve(),6)     # optional - requires Glpk or COIN-OR/CBC 
     708            sage: round(p.solve(),6)     # optional - GLPK, CBC 
    709709            6.666667 
    710710 
    711711        There are two different ways to add the constraint 
     
    735735            sage: p.set_objective(x[1] + 5*x[2]) 
    736736            sage: p.add_constraint(x[1] + 0.2*x[2] <= 4) 
    737737            sage: p.add_constraint(1.5*x[1] + 3*x[2] <= 4) 
    738             sage: p.solve()     # optional - requires Glpk or COIN-OR/CBC 
     738            sage: p.solve()     # optional - GLPK, CBC 
    739739            6.6666666666666661 
    740740 
    741741 
     
    10481048            sage: p.set_objective(x[1] + 5*x[2]) 
    10491049            sage: p.add_constraint(x[1] + 0.2*x[2], max=4) 
    10501050            sage: p.add_constraint(1.5*x[1] + 3*x[2], max=4) 
    1051             sage: round(p.solve(),6)  # optional - requires Glpk or COIN-OR/CBC 
     1051            sage: round(p.solve(),6)  # optional - GLPK, CBC 
    10521052            6.666667 
    1053             sage: p.get_values(x)     # optional random - requires Glpk or COIN-OR/CBC 
     1053            sage: p.get_values(x)     # optional random - GLPK, CBC 
    10541054            {0: 0.0, 1: 1.3333333333333333} 
    10551055 
    10561056         Computation of a maximum stable set in Petersen's graph:: 
     
    10621062            sage: for (u,v) in g.edges(labels=None): 
    10631063            ...       p.add_constraint(b[u] + b[v], max=1) 
    10641064            sage: p.set_binary(b) 
    1065             sage: p.solve(objective_only=True)     # optional - requires Glpk or COIN-OR/CBC 
     1065            sage: p.solve(objective_only=True)     # optional - GLPK, CBC 
    10661066            4.0 
    10671067        """ 
    10681068 
     
    12591259 
    12601260         Tests of GLPK's Exceptions:: 
    12611261 
    1262             sage: p.solve(solver="GLPK") # optional - requires GLPK 
     1262            sage: p.solve(solver="GLPK") # optional - GLPK 
    12631263            Traceback (most recent call last): 
    12641264            ... 
    12651265            MIPSolverException: 'GLPK : Solution is undefined' 
     
    12751275 
    12761276         Tests of GLPK's Exceptions:: 
    12771277 
    1278             sage: p.solve(solver="GLPK") # optional - requires GLPK 
     1278            sage: p.solve(solver="GLPK") # optional - GLPK 
    12791279            Traceback (most recent call last): 
    12801280            ... 
    12811281            MIPSolverException: 'GLPK : Solution is undefined' 
  • sage/numerical/mip_coin.pyx

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/numerical/mip_coin.pyx
    a b  
    3636    Solving a simple Linear Program using Coin as a solver 
    3737    (Computation of a maximum stable set in Petersen's graph):: 
    3838 
    39         sage: from sage.numerical.mip_coin import solve_coin     # optional - requires Cbc 
     39        sage: from sage.numerical.mip_coin import solve_coin     # optional - CBC 
    4040        sage: g = graphs.PetersenGraph() 
    4141        sage: p = MixedIntegerLinearProgram(maximization=True) 
    4242        sage: b = p.new_variable() 
     
    4444        sage: for (u,v) in g.edges(labels=None): 
    4545        ...       p.add_constraint(b[u] + b[v], max=1) 
    4646        sage: p.set_binary(b) 
    47         sage: solve_coin(p,objective_only=True)     # optional - requires Cbc 
     47        sage: solve_coin(p,objective_only=True)     # optional - CBC 
    4848        4.0 
    4949    """ 
    5050    # Creates the solver interfaces 
  • sage/numerical/mip_cplex.pyx

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/numerical/mip_cplex.pyx
    a b  
    3333    Solving a simple Linear Program using CPLEX as a solver 
    3434    (Computation of a maximum stable set in Petersen's graph):: 
    3535 
    36         sage: from sage.numerical.mip_cplex import solve_cplex     # optional - requires Cplex 
     36        sage: from sage.numerical.mip_cplex import solve_cplex     # optional - CPLEX 
    3737        sage: g = graphs.PetersenGraph() 
    3838        sage: p = MixedIntegerLinearProgram(maximization=True) 
    3939        sage: b = p.new_variable() 
     
    4141        sage: for (u,v) in g.edges(labels=None): 
    4242        ...       p.add_constraint(b[u] + b[v], max=1) 
    4343        sage: p.set_binary(b) 
    44         sage: solve_cplex(p,objective_only=True)     # optional - requires Cplex 
     44        sage: solve_cplex(p,objective_only=True)     # optional - CPLEX 
    4545        4.0 
    4646    """ 
    4747 
  • sage/numerical/mip_glpk.pyx

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/numerical/mip_glpk.pyx
    a b  
    3838    Solving a simple Linear Program using Coin as a solver 
    3939    ( Computation of a maximum stable set in Petersen's graph ):: 
    4040 
    41         sage: from sage.numerical.mip_glpk import solve_glpk    # optional - requires Glpk 
     41        sage: from sage.numerical.mip_glpk import solve_glpk    # optional - GLPK 
    4242        sage: g = graphs.PetersenGraph() 
    4343        sage: p = MixedIntegerLinearProgram(maximization=True) 
    4444        sage: b = p.new_variable() 
     
    4646        sage: for (u,v) in g.edges(labels=None): 
    4747        ...       p.add_constraint(b[u] + b[v], max=1) 
    4848        sage: p.set_binary(b) 
    49         sage: solve_glpk(p, objective_only=True)     # optional - requires Glpk 
     49        sage: solve_glpk(p, objective_only=True)     # optional - GLPK 
    5050        4.0 
    5151    """ 
    5252 
     
    120120        sage: x = p.new_variable() 
    121121        sage: p.set_objective(x[1] + x[2]) 
    122122        sage: p.add_constraint(-3*x[1] + 2*x[2], max=2,name="OneConstraint") 
    123         sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires GLPK 
     123        sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - GLPK 
    124124 
    125125 
    126126    For information about the MPS file format : 
     
    161161        sage: x = p.new_variable() 
    162162        sage: p.set_objective(x[1] + x[2]) 
    163163        sage: p.add_constraint(-3*x[1] + 2*x[2], max=2) 
    164         sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires GLPK 
     164        sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - GLPK 
    165165 
    166166    For more information about the LP file format : 
    167167    http://lpsolve.sourceforge.net/5.5/lp-format.htm 
  • sage/numerical/optimize.py

    diff -r 556bb66e4c6d -r 49971fc086c8 sage/numerical/optimize.py
    a b  
    697697    `1/5, 1/4, 2/3, 3/4, 5/7`:: 
    698698 
    699699        sage: from sage.numerical.optimize import binpacking 
    700         sage: print sorted(binpacking([1/5,1/3,2/3,3/4, 5/7])) # optional - requires GLPK CPLEX or CBC  
     700        sage: print sorted(binpacking([1/5,1/3,2/3,3/4, 5/7])) # optional - GLPK, CBC  
    701701        [[1/5, 3/4], [1/3, 2/3], [5/7]] 
    702702 
    703703    One way to use only three boxes (which is best possible) is to put 
     
    707707    Of course, we can also check that there is no solution using only two boxes :: 
    708708 
    709709        sage: from sage.numerical.optimize import binpacking 
    710         sage: binpacking([0.2,0.3,0.8,0.9], k=2)              # optional - requires GLPK CPLEX or CBC 
     710        sage: binpacking([0.2,0.3,0.8,0.9], k=2)              # optional - GLPK, CBC 
    711711        Traceback (most recent call last): 
    712712        ... 
    713713        ValueError: This problem has no solution !