lcz

994 Reputation

11 Badges

6 years, 128 days
changsha, China

MaplePrimes Activity


These are questions asked by lcz

I input this codes:

latex((4*n-1)/9-7/16*n)

\frac{n}{144}-\frac{1}{9}

This is not the output I expected.  I would like to obtain an expression similar to the one below.

\frac{4 n-1}{9}-\frac{7}{16}n

How can I achieve this, as Maple seems to have processed it internally.

Does maple over-understand the expression.

This question was inspired by https://www.mapleprimes.com/questions/235613-Convert-A-List-With-Nested-Ordered-Sets.

I want to replace several characters of a string separately. 

s:="[ (0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8),(8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]"

Like this their will be many say n element then I need to a list as 

{{0,1},{1,2},{1,10},......}

I took the for-loop as follows, but I'm wondering if there's a more concise way to deal with it.

with(StringTools):
L:="[ (0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8),(8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]":    
L1:=["(",")","[","]"]:
L2:=["{","}","{","}"]:
X:=L:
for i from 1 to nops(L1) do
X:=SubstituteAll(X,L1[i],L2[i]);
end do:
parse(X)

{{0, 1}, {1, 2}, {1, 10}, {2, 3}, {3, 4}, {4, 5}, {4, 9}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {10, 11}, {11, 12}, {11, 16}, {12, 13}, {13, 14}, {14, 15}, {15, 16}}

I know that a function acting repeatedly can use f @@ n, for example,

(sin@@2)(x);

But if f  has some  arguments, can it still be used?

Here is a graph (g.txt) in Graphlet (gml) format that I threw up with another program. I want to import it by maple. 

I am expecting to do two things:

  • Import the graph correctly;
  • draw the graph according to the vertex position, vertex color, vertex shape and edge color etc. in the file.

This question may come from https://www.mapleprimes.com/questions/235457-How-To-Draw-A-Directed-but-Maybe-Not-Acyclic. My intention is to use this format to efficiently pass graphs and other attributes such as vertex positions, vertex colors, and edge colors. 

However maple doesn't seem to be able to handle them even it cannot handle  the above first point well.

Import ("G:\\test\\g.gml");
# or 
GraphTheory:-ImportGraph ("G:\\test\\g.gml",graphlet)

Error, (in Import) incorrect syntax in parse: unexpected number (near 12th character of parsed string)

Error, (in GraphTheory:-ImportGraph) incorrect syntax in parse: unexpected number (near 12th character of parsed string)

I'm not sure what type of the mistake is here.

 

Mathematica can do it nicely:

g=Import["G:\\test\\g.gml"]

List @@@ PropertyValue[g, VertexLabels]
GraphEmbedding[g]

 

{{8, "x8"}, {12, "b3"}, {14, "x14"}, {2, "b2"}, {13, "x13"}, {5, 
  "r3"}, {7, "r5"}, {9, "r6"}, {11, "x11"}, {6, "r4"}, {1, "b1"}, {15,
   "x15"}, {3, "r1"}, {4, "r2"}, {10, "x10"}}

{{1080, 1440}, {480, 320}, {660, 560}, {420, 160}, {1380, 880}, {1020,
   720}, {720, 880}, {660, 800}, {2160, 0}, {0, 0}, {1500, 
  480}, {1320, 800}, {1800, 240}, {900, 1120}, {1080, 1360}}

PropertyValue[g, VertexStyle]

 

I have a vector (matrix) that looks like this. I want to save it to txt text. But the Export function doesn't seem to do that.

M:=Vector[column](10, [{{a, b}, {b, c}}, {{d, e}, {e, f}},
{{d, f}, {e, f}}, {{a, h}, {h, i}}, {{a, i}, {h, i}},
{{d, e}, {d, f}}, {{a, h}, {a, i}},{{c, d}}, {{a, b}, {a, c}}, {{a, c}, {b, c}}]);
Export(M,"E:\\M.txt");

Error, (in Export) invalid input: Export expects its 1st argument, input, to be of type string when target=file, but received Vector(10, [{{a, b}, {b, c}},{{d, e}, {e, f}},{{d, f}, {e, f}},{{a, h}, {h, i}},{{a, i}, {h, i}},{{d, e}, {d, f}},{{a, h}, {a, i}},{{c, d}},{{a, b}, {a, c}},{{a, c}, {b, c}}])
 

I found that I can save it in xsl format.

with(ExcelTools): Export(M, "E:\\M.xls");

How to save M in txt format below?

An edge cut is a set of edges that, if removed from a connected graph, will disconnect the graph.

A minimal edge cut is an edge cut such that if any edge is put back in the graph, the graph will be reconnected.

A minimum edge cut is an edge cut such that there is no other edge cut containing fewer edges.

Note that a minimum edge cut is always minimal, but a minimal edge cut is not always minimum. 

For example: 

Fig. 1 shows the original graph.

Fig. 2 shows a minimum (and therefore minimal) edge cut.

Fig. 3 shows a minimal edge cut (which is not minimum).

 

 

I'd like to find all (not one) minimal edge cuts of the following graph G.

g:= "S~tIID@OI?{@n~V?goYEDOWd?qI?sJ?[C";
G := GraphTheory:-ConvertGraph(g);
GraphTheory:-DrawGraph(G)

How to find its all minimal edge cuts? I have searched Literature [1] for the corresponding polynomial algorithm (which you can view). But I don't see any code implementation. 

For the above graph (with 20 vertices and 72 edges), perhaps a violent search would be possible.

[1] Karzanov, A.V., Timofeev, E.A. Efficient algorithm for finding all minimal edge cuts of a nonoriented graph. Cybern Syst Anal 22, 156–162 (1986). https://doi.org/10.1007/BF01074775

4 5 6 7 8 9 10 Last Page 6 of 25