Carl Love

Carl Love

26488 Reputation

25 Badges

12 years, 308 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@ I think that your Cloud suggestion applies to Maple Calculator. The OP here is using Maple Flow.

@Brian Hanley You say that you can "still click into and see the old M". This implies that is displayed on screen. In that case you should delete it from the screen (with Ctrl-Del) as well as deleting it from the "kernel" memory by one of the methods already mentioned. The simplest is M:= 'M'. The display memory and kernel memory are separate.

@ecterrab I only said that I was skeptical about it; I didn't say that it doesn't work in general. Skeptical means that I saw it as the likely cause of the error. It turns out that my skepticism was correct in this case. This is not the first time that I've encountered an error caused by using assuming real with no variables specified. (I don't remember details of the earlier case.)

Suppose I were to write a command that used keyword parameters. How would I tell assuming about those keywords? Does a mechanism for that exist?

@lcz Yes, clearly the WeightMatrix should be symmetric. I can't see the problem in your code. The first for-loop is redundant; it should be replaced by just AddEdge(gnew0, addedges). However, that is not the cause of the asymmetric matrix.

I was wrong to set any edge weights to 3. Although some edges in the resulting graph come from combining 3 edges in the original, their weight should only be 2. Edges in series through the deleted vertex do not contribute twice to the flow. But when edges originating at the non-deleted vertex are combined, their flows must be added. So change Contract to

Contract:= proc(G::Graph, e::And(set({string, symbol, integer}), 2 &under nops))
description "Remove edge from G by combining end vertices. Output is weighted.";
uses GT= GraphTheory;
local 
    V:= GT:-Vertices(G), n:= nops(V), J:= table(V=~[$n]), 
    W:= GT[`if`(op(2,G)=':-weighted', WeightMatrix, AdjacencyMatrix)](G), 
    u:= J[e[1]], v:= J[e[2]], R:= [1..v-1, v+1..n]
;
    try if W[u,v]=0 then error fi catch: error "edge %1 not found", e end try;
    W[u]+= W[v]; W[u,u]:= 0; 
    GT:-Graph(V[R], rtable(symmetric, W[R,R]))
end proc
:

The only difference is the change of 2*W[v] to just W[v].

@Deeshani Your expression has unbalanced parentheses. You also have numerous unnecessary pairs of parentheses. Although not erroneous, they only make it more confusing and difficult to correct. You can't correct unbalanced parentheses by adding pairs of parentheses.

@Cata I think that your way is better in this case. My way is more general, but is not as clear.

@lcz Here is the revised edge-contraction procedure. Surprisingly, it's simpler than the original.

Contract:= proc(G::Graph, e::And(set({string, symbol, integer}), 2 &under nops))
description "Remove edge from G by combining end vertices. Output is weighted.";
uses GT= GraphTheory;
local 
    V:= GT:-Vertices(G), n:= nops(V), J:= table(V=~[$n]), 
    W:= GT[`if`(op(2,G)=':-weighted', WeightMatrix, AdjacencyMatrix)](G), 
    u:= J[e[1]], v:= J[e[2]], R:= [1..v-1, v+1..n]
;
    try if W[u,v]=0 then error fi catch: error "edge %1 not found", e end try;
    W[u]+= 2*W[v]; W[u,u]:= 0; 
    GT:-Graph(V[R], rtable(symmetric, W[R,R]))
end proc
:
GT:= GraphTheory:
g:= GT:-ConvertGraph("O~tIID@wL~j`PbOqgLJ@p");
g1:= Contract(Contract(g, {1,3}), {5,6});
plots:-display(GT:-DrawGraph~(<g | g1>));
GT:-MaxFlow(g1,1,4)[1];

 

@lcz For our immediate purpose here (computing MaxFlow), we can use weighted edges to simulate multiple edges. Each original pair of edges through a deleted vertex results in a combination of 2 or 3 edges in the final graph, for which we can use weights 2 or 3. To see that it's possibly 3, consider contracting edge {1,3} from the graph 

g:= GraphTheory:-Graph({[{1,2}, 1], [{1,3}, 1], [{2,3}, 1]});

with 3 being the removed vertex. The resulting graph should be

g1:= GraphTheory:-Graph({[{1,2}, 3]});

I will rewrite Contract to do its work by addition of rows and columns of the weight matrix, which I'll construct if needed (using MakeWeighted, of course), followed by deletion of a row and a column. The weight matrix and vertex list are sufficient for the Graph command. I include the vertex list so that the vertices don't get renumbered, which would cause confusion for the user.

It's clear that the following sentence (excerpted from the passage that I quoted above) in the paper is incorrect:

  • Then, each edge is replaced by two oppositely directed arcs, the capacity of each arc is set to unity. 

The "unity" is incorrect. And Maple doesn't require us to use a pair of arcs instead of an edge, although some other software likely does.

@DSP514 The colons and semicolons are statement separators. The colon suppresses the display of the final result of the statement that precedes it; the semicolon does not suppress it. 

@bstuan "Exactly when" is poor phrasing. "If and only if" would be better. So, don't fret about not understanding it at first.

@bstuan The theorem you just posted states "int(f(x), x= a..b) converges exactly when int(g(x), x= a..b) converges." That means that they either both converge or both diverge. For your problem, they both diverge.

@bstuan The limit being 2 is fine for proving divergence. See https://math.uchicago.edu/~tghyde/LimitComparison.pdf

@bstuan You wrote:

  • My mistake! Sorry for my incorrect word usage.I often use the word "Convergence" to generally refer to the convergence or non-convergence (divergence) of a series or a improper integral.

I think that your original phrasing "convergence property of the following improper integral can be checked by the comparison method" is understandable.

@tomleslie The OP needs to find a function g(x) such that 

  • there exists an a > 0 such that 0 <= g(x) <= f(x) for all x in the open interval 0 < x < a,
  • g(x) has an easy-to-find antiderivative,
  • int(g(x), x= 0..a) = infinity,

in order to prove that int(f(x), x= 0..1) diverges (by comparison test).

Here is a procedure to do a single edge contraction:

Contract:= proc(G::Graph, e::And(set({string, symbol, integer}), 2 &under nops))
description "Remove an edge from G by combining its end vertices.";
uses GT= GraphTheory;
local 
    V:= GT:-Vertices(G), n:= nops(V), J:= table(V=~[$n]), E:= rtable(op(4,G)), 
    u:= J[e[1]], v:= J[e[2]], P:= v+1..n, R:= [1..v-1, P]
;
    E[u]:= (E[u] union E[v]) minus {u,v};
    GT:-Graph(V[R], subsindets(subs(v= u, E[R]), integer[P], `-`, 1))
end proc
:
GT:= GraphTheory:
G:= GT:-SpecialGraphs:-PetersenGraph():
GT:-Edges(G)[1];
                             {1, 2}
G1:= Contract(G, {1,2});
G1 := Graph 10: an undirected unweighted graph with 9 vertices and 14 edge(s)

plots:-display(GT:-DrawGraph~(<G | G1>));

Since we're always going to do two edge contractions, some efficiency can be had by doing them both at once. But I'd rather finish the algorithm first and come back to that later.

First 49 50 51 52 53 54 55 Last Page 51 of 688