lcz

994 Reputation

11 Badges

6 years, 131 days
changsha, China

MaplePrimes Activity


These are replies submitted by lcz

@acer I tried a non-programming method. First we convert this work document into pdf, then import it into inkscape, and then convert it into svg. See the attached file. The pdf format is a vector format, so I feel that pdf and svg have some kind of close connection.

table.zip

@Carl Love Thank you very much. folding is what I need.

@mmcdara I've never been very happy with the sketchiness of Maple's help documentation. More than one place, for example: How to use TSPLIB (.tsp) Format .

@Kitonum Your approach for the problem is nice, but I would love to consider of a more general replacement. For example, the number of elements in each bracket is not necessarily the same.

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

Still after the above substitution, we have

L1:=["(",")","[","]"]:
L2:=["{","}","{","}"]:
X:=L:
for i from 1 to nops(L1) do
X:=SubstituteAll(X,L1[i],L2[i]);
end do:
parse(X)

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

It is easy to see that SubstituteAll is used four times in the for-loop, and I wonder if there is a more concise way to write it. 

This is the key to my question, how a function with arguments can be repeatedly applied to an object. Note that these arguments are still changing each time. For example, SubstituteAll(X,L1[i],L2[i])

@tomleslie I sometimes encounter this situation too. Usually it's an output from another program (may be Java, C... ) that  maple may not recognize it.

[ (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 usually use some text tools (like vs code) for replacement and sometimes even regular replacement. Maple seems to be able to do the same thing.

with(StringTools):
with(GraphTheory):
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)]";    
l:=parse(SubstituteAll(SubstituteAll(s,"(","{"),")","}"));
DrawGraph(Graph({op(l)}))

 

@sursumCorda Thanks! It is well. What have you changed about the original text to make it readable? It retains at least the information of positions of vertices of the graph.

GraphTheory:-GetVertexPositions(g)

[[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]]

 

@mmcdara It still doesn't seem to work.

We note that Import function is valid for the file with gml format created by maple itself.

HerschelG := GraphTheory:-SpecialGraphs:-HerschelGraph()
GraphTheory:-ExportGraph(HerschelG,"G:/test/herschel.gml",graphlet)
g:=Import ("G:/test/herschel.gml")
GraphTheory:-DrawGraph(g)

Creator "Maple : maplesoft.com"
graph [
    directed 0
    node [
        id 1
        graphics [
            x -1
            y 0
        ]
    ]
    node [
        id 2
        graphics [
            x 0
            y .75
        ]
    ]
    node [
        id 3
        graphics [
            x 1
            y 0
        ]
    ]
    node [
        id 4
        graphics [
            x 0
            y -.75
        ]
    ]
    node [
        id 5
        graphics [
            x -.5
            y 0
        ]
    ]
    node [
        id 6
        graphics [
            x -.25
            y .25
        ]
    ]
    node [
        id 7
        graphics [
            x .25
            y .25
        ]
    ]
    node [
        id 8
        graphics [
            x .5
            y 0
        ]
    ]
    node [
        id 9
        graphics [
            x .25
            y -.25
        ]
    ]
    node [
        id 10
        graphics [
            x -.25
            y -.25
        ]
    ]
    node [
        id 11
        graphics [
            x 0
            y 0
        ]
    ]
    edge [
        source 1
        target 2
    ]
    edge [
        source 1
        target 4
    ]
    edge [
        source 1
        target 5
    ]
    edge [
        source 2
        target 3
    ]
    edge [
        source 2
        target 6
    ]
    edge [
        source 2
        target 7
    ]
    edge [
        source 3
        target 4
    ]
    edge [
        source 3
        target 8
    ]
    edge [
        source 4
        target 9
    ]
    edge [
        source 4
        target 10
    ]
    edge [
        source 5
        target 6
    ]
    edge [
        source 5
        target 10
    ]
    edge [
        source 6
        target 11
    ]
    edge [
        source 7
        target 8
    ]
    edge [
        source 7
        target 11
    ]
    edge [
        source 8
        target 9
    ]
    edge [
        source 9
        target 11
    ]
    edge [
        source 10
        target 11
    ]
]

From the above exported gml file, it stores information about vertices, edges and the coordinates of the vertices of  the Herschel graph. But it's not clear to me  what kind of gml format maple accepts. I don't know what information can be included in the standard gml format and I don't know where I can view it.

@sursumCorda  I was wondering what graph format would store the vertex positions. This will make it easier to import or export. I opened graphml and didn't see what I wanted to see. This might be another interesting question.

@dharr sursumCorda 100 I don't know much about  algorithms of Layered graph drawing.I would be happy to know if bending some edges is necessary for some graphs.

We know that Maple's graph theory package does not support drawing curves (used to represent  edges). We hope that does not to be a reason that some edges overlap. 

Here's what I did with Gephi. It can load Graphviz (The "dot" tool in Graphviz produces layered drawings.). Each edge is straight, but they do not overlap.

 

gr_graphml.txt

@dharr From the discussion below, it appears that there is no polynomial algorithm for finding all minimal cuts. I feel that I have misread Literature [1], or the result of Literature [1] itself is wrong.

@dharr Yes. The purpose of my calculation of all the minimum cuts is to observe some characteristics of edge cuts of some  graphs. The applied meaning is weak. As for the problem with the function  Iterator:-Combination  you mentioned, thanks very much for the reminder.

@dharr I just found an old post from 15 years ago, but the problem in it is finding all  minimum edge cuts for  two specific vertices in a graph. 

@dharr That's great. To be honest, I didn't  understand the method in Reference [1].

@mmcdara The second method is good enough, unless I find some specific examples to fault it (but also reflects the need for further improvement). 

Bezier:=proc(x0,y0,x1,y1,x2,y2,x3,y3)
local f,g,c,l1,l2,l3,p0,p1,p2,p3,first, last;
f:=t->x0*(1-t)^3+3*x1*t*(1-t)^2+3*x2*t^2*(1-t)+x3*t^3:
g:=t->y0*(1-t)^3+3*y1*t*(1-t)^2+3*y2*t^2*(1-t)+y3*t^3:
first := select(is, [solve((f(t)^2+g(t)^2)=0.02^2)], positive)[]:
last  := 1-first:
c     := plot([f(t),g(t),t=first..last],thickness=2,scaling=constrained, color=blue,axes=none):
p0    := disk([x0,y0],0.02,color=black):
p1    := disk([x3,y3],0.02,color=black):
display(c, p0, p1)
end:

 

 

x0:=0:   y0:=0:
x1:=0.5:  y1:=0.9:
x2:=-2:  y2:=0.2:
x3:=0.3:  y3:=0:
Bezier(x0,y0,x1,y1,x2,y2,x3,y3)

x0:=0:   y0:=0:
x1:=0.5:  y1:=0.5:
x2:=0:  y2:=0.5:
x3:=0.3:  y3:=0:
Bezier(x0,y0,x1,y1,x2,y2,x3,y3)

 

 

 

 

@dharr  I will post a new qustion.

2 3 4 5 6 7 8 Last Page 4 of 16