lcz

667 Reputation

11 Badges

3 years, 172 days
changsha, China

MaplePrimes Activity


These are replies submitted by lcz

@vs140580 I don't understand what you mean by that. 

You say:

  •  I need to see the vertex a big labels , edges how they are moving exactly in the graph more clearly which edge is exactly from which vertex to which after converting to pdf.

Do you mean to increase the size of the vertices and  thier labels ? The PDF generated by Gephi is a vector image, and you can resize  it without distortion.

F_0F_1_3.pdf

 

@vs140580 I am not familiar with the algorithmic problem of how to generate a connected planar graph. I am also a beginner in ogdf. So far I haven't learned how to build it locally (Windows).

I recently learned that python seems to provide the interface (https://pypi.org/project/ogdf-python/), but again,  it need source codes of ogdf to build it locally. (I haven't seen a detailed step by step process for building ogdf for windows).  But no matter how, you can click on the link  (ogdf-python) . Then enter the following code I wrote.

# uncomment if you didn't set this globally:
# %env OGDF_BUILD_DIR=~/ogdf/build-debug
from ogdf_python import ogdf, cppinclude
cppinclude("ogdf/basic/graph_generators/randomized.h")
cppinclude("ogdf/planarity/PlanarizationLayout.h")

G = ogdf.Graph()
ogdf.setSeed(1)
ogdf.randomPlanarConnectedGraph(G, 10, 15)
GA = ogdf.GraphAttributes(G, ogdf.GraphAttributes.all)
for n in G.nodes:
    GA.label[n] = "a%s" % n.index()

SL = ogdf.PlanarizationLayout()
SL.call(GA)
ogdf.GraphIO.drawSVG(GA, "sugiyama-simple.svg")
GA

As for how Maple calls it, I don't know yet. Maybe I'll learn it in the future.

ogdf is a self-contained C++ library for graph algorithms, in particular for (but not restricted to) automatic graph drawing. It offers sophisticated algorithms and data structures to use within your own applications or scientific projects.  

see this :https://ogdf.github.io/doc/ogdf/group__graph-generators.html#gae9de58fd22ae2533f0d81d450d4bf985

randomPlanarConnectedGraph()

void ogdf::randomPlanarConnectedGraph ( Graph &  G,
    int  n,
    int  m 
  )    

Creates a random connected (simple) planar (embedded) graph.

Parameters
G is assigned the generated graph.
n is the number of nodes of the generated graph.
is the number of edges of the generated graph.
Note
n has a lower bound of 1, and m has a lower bound of n and an upper bound of \(3n-6\). The supplied values are adjusted if they are out of these bounds.

@Carl Love Thank you so much.  A small application is the rewriting of the function of the k-power of a graph.

gpower:=proc(g,k)
local verticesofg;
verticesofg:=GraphTheory:-Vertices(g):
RelationGraph(
      proc(a,b)
        local dis;
        dis:= GraphTheory:-Distance(g,a,b);
        dis<=k and  dis<>0;
      end proc,
               verticesofg) 
end proc

s:=gpower(PathGraph(10),2);DrawGraph(s)
s := `Graph 4: an undirected unweighted graph with 10 vertices and 17 edge(s)`

                                                   

Edit: Sorry, I didn't notice that you had written down the powers of a graph.  Sure, your unions algorithm is faster.

@Carl Love Thank you.  It's almost late at night here, and I don't have my computer with me. So I can't feel your wonderful code yet. But I am fully convinced that it is correct. As far as the lexicographic product is concerned, I am probably more interested in the panning implementation of RelationGraph in maple. Maybe it's not always the most effective. But it can reflect the degree of abstraction of certain graph operations. And not just some graph operations in isolation.

@tomleslie By definition, lexicographic product and cartesian product,  are different binary operations on graphs. The cartesian product of G and H is a subgraph of the lexicographic product of G and H. 

The difference between them lies in the following restrictions.

Cartesian product:

  •  iff u1 is adjacent to u2 and v1 = v2 

lexicographic product:

  •  iff u1 is adjacent to u2

The lexicographic product is also known as graph substitution, since lexicographic product of G  and H  can be obtained from G by substituting a copy Hu of H for every vertex u of G and then joining all vertices of Hu with all vertices of Hv if  uv in  E(G).

 

@acer OpenMaple might be what I mean. I'm going to open up a new question in order to elaborate on my question.

@acer Great! By the way, I wonder if Maple could package some codes into executable files, even including some invisible source codes. The application scenario is that we can call an executable file generated with Maple on in own Python (or C, java...) program.

@vv I saw some vertex boundaries crowding each other in the drawing.  I'd like to tweak the picture a little bit, hopefully to make it look better. but the following codes didn't work.

with(GroupTheory):
with(GraphTheory):
g:=DrawSubgroupLattice(SmallGroup(200, 31), labels = ids, output=graph):
GraphTheory:-DrawGraph(g, size=[1200,800],
stylesheet=[vertexborder  = false,vertexfont= [Arial, 10],vertexfontcolor = black,
edgecolor= " Burlywood",edgethickness   =0.6,vertexpadding =0.5]);

So I looked at the properties of g by GetGraphAttribute , and I saw something strange.

GetGraphAttribute(g)
[highlighted_edges = {{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}, {1, 12}, {1, 13}, {1, 14}, {1, 15}, {1, 16}, {1, 17}, {1, 18}, {1, 19}, {1, 20}, {2, 21}, {2, 32}, {2, 42}, {3, 22}, {3, 33}, {3, 43}, {4, 23}, {4, 34}, {4, 42}, {5, 23}, {5, 35}, {5, 43}, {6, 24}, {6, 36}, {6, 42}, {7, 25}, {7, 37}, {7, 42}, {8, 21}, {8, 38}, {8, 43}, {9, 25}, {9, 39}, {9, 43}, {10, 24}, {10, 40}, {10, 43}, {11, 22}, {11, 41}, {11, 42}, {12, 31}, {12, 48}, {12, 50}, {12, 52}, {12, 54}, {12, 56}, {12, 58}, {13, 31}, {13, 49}, {13, 51}, {13, 53}, {13, 55}, {13, 57}, {13, 59}, {14, 21}, {14, 22}, {14, 23}, {14, 24}, {14, 25}, {14, 26}, {14, 27}, {14, 28}, {14, 29}, {14, 30}, {14, 31}, {14, 44}, {14, 45}, {14, 46}, {14, 47}, {14, 60}, {14, 61}, {15, 44}, {15, 54}, {15, 57}, {15, 62}, {16, 45}, {16, 55}, {16, 56}, {16, 62}, {17, 46}, {17, 48}, {17, 51}, {17, 62}, {18, 47}, {18, 49}, {18, 50}, {18, 62}, {19, 42}, {19, 43}, {19, 58}, {19, 59}, {19, 60}, {19, 62}, {20, 32}, {20, 33}, {20, 34}, {20, 35}, {20, 36}, {20, 37}, {20, 38}, {20, 39}, {20, 40}, {20, 41}, {20, 52}, {20, 53}, {20, 61}, {20, 62}, {21, 63}, {21, 68}, {21, 83}, {22, 64}, {22, 69}, {22, 83}, {23, 65}, {23, 70}, {23, 83}, {24, 66}, {24, 71}, {24, 83}, {25, 67}, {25, 72}, {25, 83}, {26, 63}, {26, 73}, {26, 82}, {27, 65}, {27, 74}, {27, 82}, {28, 66}, {28, 75}, {28, 82}, {29, 67}, {29, 76}, {29, 82}, {30, 64}, {30, 77}, {30, 82}, {31, 63}, {31, 64}, {31, 65}, {31, 66}, {31, 67}, {31, 78}, {31, 79}, {31, 80}, {31, 81}, {31, 84}, {31, 85}, {32, 68}, {32, 86}, {33, 69}, {33, 87}, {34, 70}, {34, 86}, {35, 70}, {35, 87}, {36, 71}, {36, 86}, {37, 72}, {37, 86}, {38, 68}, {38, 87}, {39, 72}, {39, 87}, {40, 71}, {40, 87}, {41, 69}, {41, 86}, {42, 83}, {42, 86}, {43, 83}, {43, 87}, {44, 80}, {44, 90}, {45, 81}, {45, 90}, {46, 78}, {46, 90}, {47, 79}, {47, 90}, {48, 78}, {48, 88}, {49, 79}, {49, 89}, {50, 79}, {50, 88}, {51, 78}, {51, 89}, {52, 84}, {52, 88}, {53, 84}, {53, 89}, {54, 80}, {54, 88}, {55, 81}, {55, 89}, {56, 81}, {56, 88}, {57, 80}, {57, 89}, {58, 85}, {58, 88}, {59, 85}, {59, 89}, {60, 82}, {60, 83}, {60, 85}, {60, 90}, {61, 68}, {61, 69}, {61, 70}, {61, 71}, {61, 72}, {61, 73}, {61, 74}, {61, 75}, {61, 76}, {61, 77}, {61, 84}, {61, 90}, {62, 86}, {62, 87}, {62, 88}, {62, 89}, {62, 90}, {63, 91}, {63, 96}, {64, 92}, {64, 96}, {65, 93}, {65, 96}, {66, 94}, {66, 96}, {67, 95}, {67, 96}, {68, 91}, {68, 98}, {69, 92}, {69, 98}, {70, 93}, {70, 98}, {71, 94}, {71, 98}, {72, 95}, {72, 98}, {73, 91}, {73, 97}, {74, 93}, {74, 97}, {75, 94}, {75, 97}, {76, 95}, {76, 97}, {77, 92}, {77, 97}, {78, 99}, {79, 99}, {80, 99}, {81, 99}, {82, 96}, {82, 97}, {83, 96}, {83, 98}, {84, 91}, {84, 92}, {84, 93}, {84, 94}, {84, 95}, {84, 99}, {85, 96}, {85, 99}, {86, 98}, {87, 98}, {88, 99}, {89, 99}, {90, 97}, {90, 98}, {90, 99}, {91, 100}, {92, 100}, {93, 100}, {94, 100}, {95, 100}, {96, 100}, {97, 100}, {98, 100}, {99, 100}}, highlighted_vertices = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}]

However, I noticed that the labels of vertices of g are not the above integers 1,2..100,  but the following, not sure what highlighted_vertices above means.

Vertices(g)
[`1/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `2/1`, `5/1`, `5/1`, `5/1`, `5/1`, `5/1`, `5/1`, `4/2`, `4/2`, `4/2`, `4/2`, `4/2`, `4/1`, `4/1`, `4/1`, `4/1`, `4/1`, `4/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/1`, `10/1`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `10/2`, `25/2`, `8/3`, `8/3`, `8/3`, `8/3`, `8/3`, `20/5`, `20/5`, `20/5`, `20/5`, `20/5`, `20/2`, `20/2`, `20/2`, `20/2`, `20/2`, `20/5`, `20/5`, `20/5`, `20/5`, `20/1`, `20/4`, `20/5`, `20/5`, `50/3`, `50/3`, `50/5`, `50/5`, `50/5`, `40/10`, `40/10`, `40/10`, `40/10`, `40/10`, `40/8`, `100/6`, `100/14`, `100/16`, `200/31`]

 

I'm not familiar with the group theory involved here. So I don't know what the green vertices in the above picture represent and how to get them. So I'm not going to deal with them. They should be easy to colour in by using HighlightVertex.

s:=GetVertexPositions(g):
G1:=Graph(Vertices(g),Edges(g)):
SetVertexPositions(G1,s):
DrawGraph(G1,showlabels=true,size=[1000,1000],stylesheet=[vertexborder  = false,vertexfont      = [Arial, 10],
vertexfontcolor = black,edgecolor= " Burlywood",edgethickness   =0.6,vertexpadding =0.5])

@Carl Love Yes, it worked on my computer, too. That's great. Thank you for your patient help. Thus, we can nicely extend maple's NonIsomorphicGraphs capabilities.This is also an effective way for us to think about maple calling external programs.

 

An off-topic topic

As Maple2022 supports JUPyterlab, in Jupyterlab, the above mentioned still need to be slightly changed. The following is an example of the program plantri that generates some special planar graphs.

L2:= Import~(
    StringTools:-Split(ssystem("D:/plantri52/plantri 12 -q  -g")[2], "\n")[1..-2]
   , 
    source= direct, format= "Graph6"
): 

Because the last one of  Split(ssystem("D:/plantri52/plantri 12 -q -g")[2], "\n")  will be "". It's not recognized.

@Carl Love 

The option output=list doesn't seem to support in Import. 

 

In windows computer,  I can execute the corresponding command directly because I have compiled it.

 

@Carl Love I used the following commands and I can see the generated graphs (with graph6  type) in the error messages, but the reason for the error is unknown to me.

L2:=ImportGraph(ssystem("D:/nauty27r3/geng -c -b 6 -g"),graph6, output=list):

Error, invalid input: GraphTheory:-ImportGraph expects its 1st argument, filename, to be of type {string, symbol}, but received [0, "E?Bw\nE?bo\nE?qo\nE?ro\nE?ow\nE?zO\nE?zo\nE?~o\nECR_\nECr_\nECZ?\nECZ_\nEEr_\nEEh_\nEEj_\nEEz_\nEFz_"]

L2:=Import(ssystem("!D:/nauty27r3/geng -c -b 5 -g"),graph6,output=list):

Error, invalid input: Import expects value for keyword parameter output to be of type {DataFrame, DataSeries, identical(anything,auto,DataFrame,DataSeries,Graph,plot,string,table,triangles,Array,Matrix,Vector,Vector[column],Vector[row],AudioTools:-Audio,ByteArray,ImageTools:-Image,Logic,logical,boolean_function,embed,html,xml)}, but received list

  @acer t's the first time I've seen it handled so beautifully. With your help, the following code works very well.

restart;
with(GraphTheory):
DrawGraph(CompleteGraph(10), layout = interactive,
          layoutoptions = [neutral_color = "pink", initial = spring],
          stylesheet = [vertexpadding=10,edgethickness=2,edgecolor= SteelBlue]):

@acer Sorry, I have added more details in the question. In general, the matrices I encounter are real symmetric, and the strange thing is that I don't see a command to evaluate all  numeric eigenvalues of a matrix so far.

@Carl Love Thank you for your explanation.  It is really not a good habit to delete a post that others have commented on easily, even if some posts may be belong themselves.This requires good website mechanics rather than ethical constraints.

1 2 3 4 5 6 7 Last Page 1 of 11