lcz

994 Reputation

11 Badges

6 years, 131 days
changsha, China

MaplePrimes Activity


These are questions asked by lcz

 

The function subsets is an iterator for generating the power set of a set one set at a time.  I wanted to get iterators for all  k -subsets , so I modified the codes for getitng  iterators for the power set in the help document.

with(combinat):
k:=3:
S := subsets({1,2,3,4,a}):
while not S[finished] do
   s1:=S[nextvalue]();
 if nops(s1)=k then 
    print(s1);
    end if;
end do:

 

 

 

But I think the iterative process is done in filtering, which means that maple runs out of power sets. It may not save time.

And of course we can use "choose" to get all k-subsets at once.

choose({1,2,3,4,a}, 3)

 

So my question is is there an iterator that takes less time to get a k-subset .

I prefer the iterator to the choose function because it saves memory and makes it easy to set some breakpoints in the program to terminate the process.

Another interesting thing is that I looked at the source code when use print and it didn't seem to show.

interface(prettyprint=2):
print(combinat:-subsets)

 

 

 

 

When I was drawing a plane graph, I found that the labels  of vertices were not displayed  and some edges even overlap when drawing because they were too close due to embedding.

restart:
with(GraphTheory):
g:=ConvertGraph("GsaCB{");
DrawPlanar(g,stylesheet=[vertexborder=false,vertexpadding=5,edgecolor = maroon,vertexcolor=gray,edgethickness=3])

So I thought that  option  Interactive  can adjust the position manually, but  at the same time I found that the style of  edges, such as the color and thickness, etc., is lost.  How to handle it? Is this a bug?

restart:
with(GraphTheory):
g:=ConvertGraph("GsaCB{");
DrawPlanar(g,stylesheet=[vertexborder=false,vertexpadding=5,edgecolor = maroon,vertexcolor=gray,edgethickness=3],layout=interactive)

I wanted to define a set of all positive integer powers of 2, and I could determine whether a number is contained in the set.

When a set is a finite set and there are not many elements, it's not hard to do. We can form the set first and then determine whether the elements are included or not.

S:={seq(2^i,i=1..100)}:
is(64,S);
is(-3,S);

true

false

Because the set of all positive integer powers of 2 is an infinite set, or rather a countable set. I thought of using the positive type to define it.

map(type, [0, 4, -2], 'And'('positive', 'satisfies'(s -> type(log2(s), 'positive'))))

[false, true, false]

Interestingly, we find that the type of judgment condition is a function, whereas positive(or integer) are symbols.

whattype('And'('positive', 'satisfies'(s -> type(log2(s), 'positive'))));
whattype(positive);
whattype(integer);

function

symbol

symbol

So my question is how does Maple define integer types or positive integers or even real numbers? In other words if I don't use the positive integer type for the above question, can I define the set of all positive integer powers of 2.

We know that the  showstat()  function can provide some available source codes, but it also provides line numbers.  I need to delete one by one to use it, which is not efficient when I want to copy and modify codes. Is there any way to directly remove those line numbers.

for exampe:

showstat(PlaneDual);

PlaneDual returns the plane dual of a planar graph G, that is, a graph with faces of G as its vertices in which two vertices are adjacent if and only if they share an edge as faces of G. Of course, this is a little different from the standard definition of plane dual. (Interlude: I estimate that the two definitions are equivalent in the case that the planar graph is 3-connected simple graph)

It's not hard to find a plane dual of a planar graph in Maple. 

g:=Graph({{1,2},{2,4},{3,4},{2,3},{1,3},{1,4},{4,5},{2,5},{1,5}});
DrawPlanar(g);

dual_g:=PlaneDual(g);
DrawPlanar(
dual_g)

Since all labels of the dual graph are used numbers 1..n in maple, I cannot see how its vertices correspond to the face of the original graph.  And further, I want to know one edge of the dual graph corresponds to which edge (should be the boundary on two faces) of the original planar graph.

Maybe input {1,4} of the dual graph and output {2,4} of the original graph.

For example, Input {1} that is a vertex of  dual graph  to get the original face {2,3,4} and if we input {1,4} of the dual graph, we will output edge {2,4} of the original graph.

I don't know if there's a good way to do that.

 

 

First 10 11 12 13 14 15 16 Last Page 12 of 25