lcz

1039 Reputation

12 Badges

6 years, 161 days
changsha, China

MaplePrimes Activity


These are questions asked by lcz

I followed the code on the website https://de.maplesoft.com/support/help/maple/view.aspx?path=updates/Maple18/GraphTheory to convert a graph to LaTeX code. However, after compiling with pdflatex, I found that some edges of the graph are jagged.

restart:    
with(GraphTheory):
with(SpecialGraphs):
S:=SoccerBallGraph():
Latex(S,FileTools:-JoinPath([currentdir(), "soccer.tex"]),300,300,true)

soccer.pdf

I suspect it's because of the converted LaTeX code.

PS: The PDF conversion issue from last time still remains unsolved in Maple 2023; see

https://www.mapleprimes.com/questions/236142-How-To-Remove-The-Mosaic-Of-Vertices.

An interval graph is an undirected graph formed from a set of intervals on the real line, with a vertex for each interval and an edge between vertices whose intervals intersect. Recognizing interval graphs  is in linear time. 

Seven intervals on the real line and the corresponding seven-vertex interval graph.

 

 

IsIntervalGraph(G) (was introduced in Maple 2022) tests whether the graph G could be expressed as an interval graph for some collection of intervals. If a graph is an interval graph, then the intervals corresponding to its vertices should be given. However,  IsIntervalGraphdoes not provide such an option, which makes it impossible for me to verify the correctness of the results or see more information.

with(GraphTheory):
G:=Graph({{1,2},{1,3},{1,4}, {4,2},{4,3}});
IsIntervalGraph(G)

true

Therefore, an option like the "certificate" option in SageMath needs to be provided.

g = Graph({1: [2, 3, 4], 4: [2, 3]})
g.show()
g.is_interval()
g.is_interval(certificate=True)

(True, {1: (0, 5), 2: (4, 6), 3: (1, 3), 4: (2, 7)})

 

 

I have looked at the source code of IsIntervalGraphand it seems to be checking whether the complement graph is comparability. I am not sure if this transformation can still find the corresponding intervals.

print(IsIntervalGraph)
proc(G::GRAPHLN)::truefalse;
    local G2;
    G2 := GraphTheory:-GraphComplement(G);
    return GraphTheory:-IsComparabilityGraph(G2);
end proc

print(IsComparabilityGraph)
proc (G::GRAPHLN, { transitiveorientation::truefalse := false, 

   usecached::truefalseFAIL := FAIL }, ` $`)::truefalse; local 

   iscomparability, L, A, result, V; A := op(4, G); result := 

   FindTransitiveOrientation(A, transitiveorientation); if 

   result = NULL then false elif transitiveorientation then V 

   := op(3, G); true, GraphTheory:-Graph(V, result) else true 

   end if end proc

 

By the way, can the  "FindTransitiveOrientation "  in the function IsComparabilityGraph be used by the user?

I compute some properties of some graphs and try to store their edge sets and their corresponding properties. I stored them using matrices, but now I want to export them to a file (csv format).

with(GraphTheory):
graphs := [seq(RandomGraphs:-RandomGraph(8, 9), 1 .. 10)]:
M0:=Edges~(graphs):
M1:=Girth~(graphs):
M2:=Diameter~(graphs):
B := Matrix(1..3,[M0,M1,M2]);
Export("E:/B.csv", B):

 

he exported file's data is messy, and it is difficult for me to observe the corresponding properties of the graphs.  I hope they can be sorted into three columns as shown below.

PS: I know that if the data has only one column, it can be done as discussed earlier

Export("E:/M.csv", M):

To make the data appear clearer, it is best to keep suitable spacing between columns.

multi_dimensional_data.mw

We can read all the graphs in a file at once, or we can use an iterative approach. But can I specify a certain number of lines to read? 

with(GraphTheory):
g:=ImportGraph("E:/5cc3free.txt", graph6, output=list)

The contents of 5cc3free.txt are as follows (all 5-vertex C_3 free connected graphs).  There are 6 lines.

D?{
D@s
DBw
DFw
DDW
DqK

The reason for wanting this kind of operation is that sometimes there are tens of thousands of graphs stored in a single file, and I want to read them in batches. For example, I want to extract the graph data from lines 1-2, 3-4, and 5-6 in batches. How can I accomplish this?

In the previous example, a small dataset was used for demonstration purposes. In the following example, which involves all 8-vertex connected graphs (see the attachment graph8c.txt), I want to extract the graphs from lines 200-300. 

I found that readline always starts reading from the first line of a file, so the efficiency may not be very high.

Here is a string, and I want to treat consecutive single digits as a single number and extract them. I can process it using regular expressions in Python. I'm not sure if Maple can handle it in a similar way.

import re
sstr1 = "124e34e243e45e56e76f34e45e23ea12e98e34e43"
num=re.findall(r'\d+', sstr1)
s=list(map(int, num))
print(s)

[124, 34, 243, 45, 56, 76, 34, 45, 23, 12, 98, 34, 43]

Is there an equivalent regular expression method in Maple?

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