ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 11 Oct 2020 14:39:24 -0500plotted real intersection but solve only shows imaginaryhttps://ask.sagemath.org/question/53835/plotted-real-intersection-but-solve-only-shows-imaginary/I plotted `x^3 - x` and its derivative `3*x^2 - 1` to get two intersections in the real plane.
plot([x^3-x,3*x^2 - 1],-3,3,color=['blue','green'],legend_label=["f","derivative"])
![intersection](/upfiles/16024461625093012.png)
However, when I solved the two with `solve(x^3-x == 3*x^2 - 1, x)`, all I get are imaginary values.
solve(x^3-x == 3x^2 - 1,x)
[x == -1/2*(1/9*I*sqrt(37)*sqrt(3) + 1)^(1/3)*(I*sqrt(3) + 1) - 2/3*(-I*sqrt(3) + 1)/(1/9*I*sqrt(37)*sqrt(3) + 1)^(1/3) + 1, x == -1/2*(1/9*I*sqrt(37)*sqrt(3) + 1)^(1/3)*(-I*sqrt(3) + 1) - 2/3*(I*sqrt(3) + 1)/(1/9*I*sqrt(37)*sqrt(3) + 1)^(1/3) + 1, x == (1/9*I*sqrt(37)*sqrt(3) + 1)^(1/3) + 4/3/(1/9*I*sqrt(37)*sqrt(3) + 1)^(1/3) + 1]
Shouldn't `solve` show me the two intersections or am I disastrously confused?cybervigilanteSun, 11 Oct 2020 14:39:24 -0500https://ask.sagemath.org/question/53835/Strategies for plotting graphs with many verticeshttps://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.
I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.
Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.
Thanks in advance ^_^ HallaSurvivorThu, 20 Aug 2020 17:45:51 -0500https://ask.sagemath.org/question/53126/Combination under constrained situation with a conditionhttps://ask.sagemath.org/question/52345/combination-under-constrained-situation-with-a-condition/Step 1: I want to take a number `n` as input from user
Step 2: We form the set `S` consisting of elements from `0` to `n*(2^{n-1})`
Step 3: Now I pick each possible two-element subsets of `S` and store it in `P`.
Step 4: Now I need to pick `n*(2^{n-1})` two-element subsets from `P`
such that each number that occurs in that set occurs exactly `n` times
neither less nor more and put them all in a list.
Example
n = 2
n*(2^{n-1}) = 2*(2^{2-1}) = 4
S = {0,1,2,3,4}
p = {(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}
Step 4 One element which satisfies condition of step 4; HERE `n = 2`.
`{(0,1),(1,2),(2,3),(0,3)}` which has `2*(2^{n-1}) = 2*(2^{2-1}) = 4` elements.
Now see in the above set
- `0` occurred `n=2` times only in `(0,1)` and `(0,3)` only
- `1` occurred `n=2` times only in `(0,1)` and `(1,2)` only
- `2` occurred `n=2` times only in `(1,2)` and `(2,3)` only
- `3` occurred `n=2` times only in `(2,3)` and `(0,3)` only
Similarly we may get for `{(0,1),(1,4),(4,2),(2,0)}` we can easily verify like above.
Now based on `n` the number of elements size etc will vary.
Kindly help if possible any one.sriramSun, 05 Jul 2020 13:36:40 -0500https://ask.sagemath.org/question/52345/How to obtain the graph having highest algebraic connectivity?https://ask.sagemath.org/question/52205/how-to-obtain-the-graph-having-highest-algebraic-connectivity/ for G in graphs.nauty_geng("10-c"):
if G.size()==11:
L = G.laplacian_matrix().eigenvalues()
L.sort()
show(L)
G.show()
Using this code I have obtained the connected graphs on 10 vertices with 11 edges. Also I have obtained the Laplacian eigenvalues also for the corresponding graphs. The second smallest eigenvalue of Laplacian matrix is called the algebraic connectivity. Now among all these graphs, I need those graphs which have highest algebraic connectivity among all the graphs on 10 vertices with 11 edges. How we can do that?KuldeepWed, 24 Jun 2020 15:24:16 -0500https://ask.sagemath.org/question/52205/Graph indexed from zerohttps://ask.sagemath.org/question/51211/graph-indexed-from-zero/ How to change vertices of a graph to that are indexed from 0?
In Mathematica: ChangeVertices.
We can change it to the adjacency matrix A and from A to the graph. A faster solution?
Ho to get a permutation of vertices?SYLASat, 02 May 2020 10:01:38 -0500https://ask.sagemath.org/question/51211/Displaying Chessboard Graphshttps://ask.sagemath.org/question/49976/displaying-chessboard-graphs/I'm looking at various graphs and their plotting methods. For the code
G = graphs.KnightGraph([3,3])
G.show()
Sage displays:
![image description](/upfiles/15820828503619033.jpg)
I'd like the vertices to be arranged in a 3 by 3 grid so that the chessboard nature of the graph is more apparent.
From the documentation [here](http://doc.sagemath.org/html/en/reference/plotting/sage/graphs/graph_plot.html) I tried specifying the position by using a dictionary:
G = graphs.KnightGraph([3,3])
pos_dict = {}
for i in range(0,2):
for j in range(0,2):
pos_dict[G.vertices()[3*i+j]] = [i*.5,j*.5]
pl = G.graphplot(pos=pos_dict)
pl.show()
This doesn't give the intended result. Even stranger, running the code multiple times shows the position of only some of the
vertices is fixed while others change position.
How can I display an n by n chessboard graph so that it's vertices form an n by n square?
dazedANDconfusedTue, 18 Feb 2020 21:38:26 -0600https://ask.sagemath.org/question/49976/Automorphism group of edge symmetryhttps://ask.sagemath.org/question/47334/automorphism-group-of-edge-symmetry/ I asked a similar question before,
https://ask.sagemath.org/question/42762/automorphism-group-of-weighted-graph/
I am curious that is there any similar function for finding "edge symmetry"?
Note: the link I provided is for "node symmetry" in a network (graph). sleeve chenThu, 01 Aug 2019 04:21:31 -0500https://ask.sagemath.org/question/47334/DiGraph, Latex, and same orientationhttps://ask.sagemath.org/question/48140/digraph-latex-and-same-orientation/Hi
1) is it possible to write in Latex in vertices and edges ?
2) depending on whether I set the value of the Population variable to 1000 or to 100000 it swaps the branches sick and not sick, so is it a possibility to keep the same orientation each time ?
p=1000 ;print "Population : "+str(p)
sr=1/1000 ;print "Sick Rate : "+str(sr)
pfr=95/100 ;print "Positive False Rate : "+str(pfr*100)+'/'+"100"
nfr=40/100 ;print "Negative False Rate : "+str(nfr*100)+'/'+"100"
PbNS=(p-p*sr)*(1-pfr);print "Positive but Not Sick : "+str(round((p-p*sr)*(1-pfr),5))
PaS=((p-(1-sr)*p))*(1-nfr); print "Positive and Sick : ",str(round(((p-(1-sr)*p))*(1-nfr),5))
print "chance to be Sick if Tested Positive : ",PaS/(PbNS+PaS)," about :",round((PaS/(PbNS+PaS)),5)," : ",\
round((PaS/(PbNS+PaS))*100,5),"%"
H0=DiGraph({0:[1,2], 1:[3,4], 2:[5,6]})
#H.set_latex_options(edge_labels=True)
H0.set_edge_label(0, 1, "Not Sick : "+str(p-sr*p)+"/" +str(p))
H0.set_edge_label(0, 2, "Sick: "+str((p-(1-sr)*p))+'/'+str(p))
# not sick branch
H0.set_edge_label(1, 3, "Not Sick \n Tested Negative: "+str(pfr*100)+'/'+"100")
H0.set_edge_label(1, 4, "\n\n\n Not Sick \n Tested Positive: "+str((1-pfr)*100)+'/'+"100")
# sick branch
H0.set_edge_label(2, 5, "Sick Tested Negative: "+str((nfr)*100)+'/'+"100")
H0.set_edge_label(2, 6, "\n\n\n\nSick Tested Positive: \n "+str((1-nfr)*100)+'/'+"100")
H0.relabel({0:str(p)+' Peoples' , 1:str(p-p*sr), 2:str(p-p*(1-sr)), \
3:str(round((p-p*sr)*pfr,5))+' \n Tested Negative and Not Sick', \
4:str(round((p-p*sr)*(1-pfr),5))+' \n Tested positive but Not Sick', \
5:str(round(((p-(1-sr)*p))*(nfr),5))+' \n Tested Negative and Sick', \
6:str(round(((p-(1-sr)*p))*(1-nfr),5))+' \n Tested Positive and Sick'})
H0.show(vertex_color='white', vertex_shape='_',edge_labels=True,figsize=[10,10],layout='tree')
[edited the 2019/10/06, below attempt to solve pb with get_pos(),see David Coudert comment]
it seems that get_pos() does not get something ?:
def ShowTreeH0(p,H0Vert,H0Pos):
sr=1/1000 ;print "Sick Rate : "+str(sr)
pfr=95/100 ;print "Positive False Rate : "+str(pfr*100)+'/'+"100"
nfr=40/100 ;print "Negative False Rate : "+str(nfr*100)+'/'+"100"
PbNS=(p-p*sr)*(1-pfr);print "Positive but Not Sick : "+str(round((p-p*sr)*(1-pfr),5))
PaS=((p-(1-sr)*p))*(1-nfr); print "Positive and Sick : ",str(round(((p-(1-sr)*p))*(1-nfr),5))
print "chance to be Sick if Tested Positive : ",PaS/(PbNS+PaS)," about :",round((PaS/(PbNS+PaS)),5)," : ",\
round((PaS/(PbNS+PaS))*100,5),"%"
H0=DiGraph({0:[1,2], 1:[3,4], 2:[5,6]})
#H.set_latex_options(edge_labels=True)
H0.set_edge_label(0, 1, "Not Sick : "+str(p-sr*p)+"/" +str(p))
H0.set_edge_label(0, 2, "Sick: "+str((p-(1-sr)*p))+'/'+str(p))
# not sick branch
H0.set_edge_label(1, 3, "Not Sick \n Tested Negative: "+str(pfr*100)+'/'+"100")
H0.set_edge_label(1, 4, "\n\n\n Not Sick \n Tested Positive: "+str((1-pfr)*100)+'/'+"100")
# sick branch
H0.set_edge_label(2, 5, "Sick Tested Negative: "+str((nfr)*100)+'/'+"100")
H0.set_edge_label(2, 6, "\n\n\n\nSick Tested Positive: \n "+str((1-nfr)*100)+'/'+"100")
H0.relabel({0:str(p)+' Peoples' , 1:str(p-p*sr), 2:str(p-p*(1-sr)), \
3:str(round((p-p*sr)*pfr,5))+' \n Tested Negative and Not Sick', \
4:str(round((p-p*sr)*(1-pfr),5))+' \n Tested positive but Not Sick', \
5:str(round(((p-(1-sr)*p))*(nfr),5))+' \n Tested Negative and Sick', \
6:str(round(((p-(1-sr)*p))*(1-nfr),5))+' \n Tested Positive and Sick'})
if H0Vert<>None and H0Vert<>None :
print " set vertice and position"
H0.set_vertices(H0Vert)
H0.set_pos(H0Pos)
H0.show(vertex_color='white', vertex_shape='_',edge_labels=True,figsize=[10,10],layout='tree')
return H0.get_vertices(),H0.get_pos()
H0Vert=None
H0Pos=None
p=1000 ;print "Population : "+str(p)
H0Vert,H0Pos=ShowTreeH0(p,H0Vert,H0Pos)
p=100000 ;print "Population : "+str(p)
H0Vert,H0Pos=ShowTreeH0(p,H0Vert,H0Pos)ortolljWed, 02 Oct 2019 05:46:03 -0500https://ask.sagemath.org/question/48140/How to count face on a bipartite graph?https://ask.sagemath.org/question/47057/how-to-count-face-on-a-bipartite-graph/I am graphing a bipartite graph but I need to rearrange the graph. The graph is generated by a list of list. One of the rearrangement guidelines is that the faces have to be surrounded by a certain amount of "white" vertices. Therefore, I wanted to create a checker function that can count the faces of the graph and count the "white" vertices around that face. If the graph doesn't have the correct amount of faces and/or the number of "white" vertices then the program will rearrange the graph. I would like some guidance on this task, what code/math I should use or if I should use a different approach. I have attached the code. If more information is needed to help, please contact me at cameron.dthomas@morehouse.edu
Thanks for your time,
Cameron Thomas
D={}
graph=Graph(D, multiedges=True)
def Dessin(S0, S1):
numVertices = len(S0)+len(S1)
G={}
#adds keys to G
for i in range(numVertices):
G[i]=(S0+S1)[i]
for i in range(len(S0)):
#print(S0[i])
for j in range(len(S0[i])):
#print(S0[i][j])
for k in range(len(S1)):
if S0[i][j] in S1[k]:
graph.add_edge(i,k + len(S0),S0[i][j])
print(G)
def color(S0, S1):
grey=[]
white=[]
for i in range(len(S0)):
grey.append(i)
for i in range(len(S1)):
white.append(i+len(S0))
return [grey,white]
Dessin(S0, S1)
color(S0, S1)
graph.graphplot(edge_labels=True, vertex_colors={'grey': color(S0,S1)[0],'white':color(S0,S1)[1]}, vertex_labels=True).show()
return(graph)
Graf([[1,5,4,3,2]],[[1],[2],[3],[4],[5]])CamDTho3Wed, 03 Jul 2019 23:18:28 -0500https://ask.sagemath.org/question/47057/Plotting Graphs with different size verticeshttps://ask.sagemath.org/question/46953/plotting-graphs-with-different-size-vertices/ Hi, I'm trying to plot a graph where all vertices have a different size, depending on a value assigned to them, so a vertex with a high value would have a larger circumference.
I don't really know where to start. Can you help me?ga38xabThu, 20 Jun 2019 05:58:49 -0500https://ask.sagemath.org/question/46953/fractional chromatic index of edge-weighted graphshttps://ask.sagemath.org/question/46900/fractional-chromatic-index-of-edge-weighted-graphs/How would you compute the fractional chromatic index of an edge-weighted graph using SAGE?
The built-in function fractional_chromatic_index seems to compute the fractional chromatic index for only unweighted graphs. For instance, if $G$ is the 5-cycle graph, its fractional chromatic index is $2.5$. But if one of the edges can be ignored, say by giving it a zero weight, then the fractional chromatic index becomes $2$.
The code and output below shows that SAGE ignores the edge-weights (notice that the edge-weights need not be integral - in the graph below, the correct value of the fractional chromatic index is 2.1, which is the maximum sum $1.1+1.0$ of weights of edges incident to a vertex):
sage: G = graphs.EmptyGraph()
sage: G.add_edges([(1,2,1.1),(2,3,1),(3,4,1),(4,5,1),(5,1,0)])
sage: G.fractional_chromatic_index()
5/2
sage:
Is there some way to get the built-in function to take edge weights into account? Or can this value be computed using some other method?Ashwin GanesanTue, 11 Jun 2019 03:52:15 -0500https://ask.sagemath.org/question/46900/Graphing Complex Functions 3D (x,y,i axes) Instead Of Color-Coded 2D (x,i)https://ask.sagemath.org/question/10368/graphing-complex-functions-3d-xyi-axes-instead-of-color-coded-2d-xi/Following [this guide to Sage][1]: and using [Sage Online][2] produced the following graphs:
![enter image description here][3]
![enter image description here][4]
It would be nice to see it in 3D instead of merely color coded. The y-axis is coming out of the picture toward us and instead of seeing the 3D surface (in x,y,i coordinates) we see a color-graph on the x-i plane.
You can do what I wish [using Maple:](http://math.stackexchange.com/questions/448397/graphing-compex-functions-3d-x-y-i-axes-instead-of-color-coded-sage/448410?noredirect=1#448410)
[1]: http://www.sagemath.org/doc/reference/plotting/sage/plot/complex_plot.html
[2]: http://www.sagenb.org/
[3]: http://i.stack.imgur.com/gw8Aj.png
[4]: http://i.stack.imgur.com/NYP76.jpgJoe HobbitSat, 20 Jul 2013 13:50:24 -0500https://ask.sagemath.org/question/10368/What are distance regular graphshttps://ask.sagemath.org/question/45960/what-are-distance-regular-graphs/ A connected graph Γ with diameter D is called distance-regular if there are constants ci,ai,bi — the so-called intersection numbers — such that for all i = 0,1,...,D, and all vertices x and y at distance i = d(x,y), among the neighbors ofy, there are ci at distance i−1 from x, ai at distance i, and bi at distance i+1. It follows that Γ is a regular graph with valency k = b0, and that ci +ai +bi = kfor all i = 0, 1, . . . , D. By these equations, the intersection numbers ai can be expressed in terms of the others, and it is standard to put these others in the so-called intersection array
{b0,b1,...,bD−1;c1,c2,...,cD}.VindieselwalkerSun, 31 Mar 2019 09:09:05 -0500https://ask.sagemath.org/question/45960/Sage Floyd algorithm in Cythonhttps://ask.sagemath.org/question/44823/sage-floyd-algorithm-in-cython/Hi
Classical Floyd algorithm computes all shortest path in a **weighted** graph and this algorithm has a $O(n^3)$ complexity (-> it can be slow). So i'm a bit surprised to see that the Cython version provided in Sage works only if `by_weight==False` meaning that all weights are 1 by default (its computes the transitive closure of the graph).
As a consequence, does it mean the only way to compute the "true" all-shortest-path in Sage is by using the pure Python implementation ?elasticaMon, 31 Dec 2018 03:53:04 -0600https://ask.sagemath.org/question/44823/Where has _circle_embedding gone?https://ask.sagemath.org/question/44467/where-has-_circle_embedding-gone/After nearly killing myself (in frustration) installing Sage 8.4 from source on OSX 10.14.1 (Mojave), I discover that a graph plotting command that I frequently use has vanished, breaking a number of my own programs.
Previously (on SageMath up to 8.2) I would do
from sage.graphs.graph_plot import _circle_embedding
in order to access this.
Now I just get
ImportError: cannot import name _circle_embedding
I can relatively easily replace this *particular* function myself, but if it were something more complicated, I would be at a loss to know how to track down the cause for its disappearance and figure out how to get it back.
So I guess the questions are: has it only vanished for me due to a botched or incomplete installation, or has it somehow been removed from Sage? In either case, how can I recover it?GordonTue, 27 Nov 2018 02:59:33 -0600https://ask.sagemath.org/question/44467/Graph with partial edge labellinghttps://ask.sagemath.org/question/43892/graph-with-partial-edge-labelling/ Hello all,
I need to draw a graph in which some edges are labelled and some edges are not.
I know how to make all the edges labelled. But I need mixed edges (some are labelled and some are not).
Kindly help me with this.
Thank youGA316Wed, 10 Oct 2018 02:04:43 -0500https://ask.sagemath.org/question/43892/creating graph with dotted edgeshttps://ask.sagemath.org/question/43872/creating-graph-with-dotted-edges/ Hello all,
I need to draw a graph in which some edges are usual and some edges are dotted. I know how to make all the edges dotted (using the option "dotted" for the parameter edge_style of plot). But I need mixed edges (some are dotted and some are usual). Kindly help me with this.
Thank you.
GA316Mon, 08 Oct 2018 11:17:43 -0500https://ask.sagemath.org/question/43872/values or names on tree branches (graph)https://ask.sagemath.org/question/43691/values-or-names-on-tree-branches-graph/ Hi
How can I make appear names (or,and) numerical values on the branches ?.
#https://ask.sagemath.org/question/43106/preserving-the-rooted-tree-layout-in-graphs/
G=Graph({1:[2,3],2:[4,5],3:[6,7]})
G.weighted(False)
G.show(layout='tree',tree_root=1)
show(G.vertices())ortolljTue, 18 Sep 2018 06:33:09 -0500https://ask.sagemath.org/question/43691/Why can't I find the spectral radius of a tree?https://ask.sagemath.org/question/43496/why-cant-i-find-the-spectral-radius-of-a-tree/ If I create some connected graphs, and ask SageMath for their spectral radius, the command never returns (well, I have only let it run for a few minutes) if the target is a tree.
Here is a simple example:
g = graphs.CompleteBipartiteGraph(1,3)
print g.spectrum()
print g.spectral_radius()
The only advertised requirement for the target is that it be strongly connected, but as it is a connected graph, this should automatically be satisfied.
Yes, I can work around by computing the spectrum and taking the biggest, but I'd still like to know why this does not work.GordonMon, 27 Aug 2018 22:23:37 -0500https://ask.sagemath.org/question/43496/class of trees or graphshttps://ask.sagemath.org/question/43454/class-of-trees-or-graphs/ [Here](http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/trees.html) we can see how to generate all the trees of order $n$ and is not upto isomorphism. But I dont want all trees of order $n$.
I want to know is there class of graphs which are particular typres of trees, like class of paths.
In general where I can find how to define class of complete graph, cycles, . . .
Kindly share the link for the documentation.
Thank you.GA316Thu, 23 Aug 2018 22:10:09 -0500https://ask.sagemath.org/question/43454/How can I generate a graph from an .mtx file?https://ask.sagemath.org/question/42866/how-can-i-generate-a-graph-from-an-mtx-file/The .mtx file contains the information of an sparse matrix in matrix market format. How can I generate the underlying graph of this matrix in SAGE?
Alternatively, since I now how to generate the .mat file from .mtx file in MATLAB, how can I generate the graph from .mat file in SAGE?
The matrix in .mtx in format is the adjacency matrix of the graph. The problem is I cannot read the matrix and generate the underlying graph in SAGE 8.2 (Jupyter).ASHSun, 08 Jul 2018 23:13:44 -0500https://ask.sagemath.org/question/42866/Show3d has no partition optionhttps://ask.sagemath.org/question/42820/show3d-has-no-partition-option/ `graph.show(partition = Pi)` works but `graph.show3d(partition =Pi)` doesn't. Is this something that might be fixed in the future? Or is there a workaround? Bjørn Kjos-HanssenWed, 04 Jul 2018 02:19:18 -0500https://ask.sagemath.org/question/42820/Automorphism group of weighted graphhttps://ask.sagemath.org/question/42762/automorphism-group-of-weighted-graph/I know we can use sage to find the group of automorphisms of a graph $G$:
G.automorphism_group().list()
However, the above way can only be used to the unweighted graph. So for example:
G = matrix([[0,10,0],
[10,0,1],
[0,1,0]])
G1 = Graph(G, weighted = True)
G1.show(edge_labels=True )
G.automorphism_group().list()
The result is:
[(), (0,2)]
However, this result is not correct (correct for unweighted case). This is because $AD\neq DA$, where
$$D = \begin{bmatrix} 0 & 0 & 1 \\\ 0 & 1 & 0 \\\ 1 & 0 & 0\end{bmatrix},$$ which is a permutation matrix and
$$A = \begin{bmatrix} 0 & 10 & 0 \\\ 10 & 0 & 1 \\\ 0 & 1 & 0\end{bmatrix},$$ which is an adjacency matrix.
Can we use SAGE to find the group of automorphisms of a graph?sleeve chenWed, 27 Jun 2018 20:22:14 -0500https://ask.sagemath.org/question/42762/Problem with .stl and Graphhttps://ask.sagemath.org/question/41702/problem-with-stl-and-graph/Hi everyone!
I have a problem with SageMath, and I need your help :).
I want to save my personal Graph from a list to a .stl file
(.stl for 3d object representation, "stereolithography").
My code:
p = [[0,0,0],[1,2,3],[2,3,1],[2,1,0],[1,3,2],[3,2,1]]
points = PointConfiguration(p)
triang = points.triangulate()
triang.save('mygraph.stl')
triang.plot(axes=False)
___
When I try to save my file it's in the .sobj extension. (I research this extension
and it's just an extension SageObject, so it's not useful for me). I want to draw
a graph with a list of point and to convert them in a .stl file.
I already tried:
- save the plot:
triang.plot().save('mygraph.stl') # Fails as there is no attribute face_list
- save the all[-1]:
triang.all[-1].save('test.stl') # Fails as PointConfiguration don't have argument all.
I don't know what is the problem, so I ask for your help.
Thank you very much.haaggenWed, 21 Mar 2018 15:48:59 -0500https://ask.sagemath.org/question/41702/Flow gives error for disconnected verticeshttps://ask.sagemath.org/question/41419/flow-gives-error-for-disconnected-vertices/ When calculating the flow between to vertices which are not connected in a graph, the method returns a ValueError. I would have assumed that it would just return 0. Here's a minimal example:
G=Graph({0:[],1:[]})
G.flow(0,1) # raises the error ValueError: vertex '0' is not in the (di)graph
If on the other hand one tries the shortest_path method it just returns a empty list, since there is not path between 0 and 1.
G.shortest_path(0,1) #returns []AckslWed, 07 Mar 2018 06:21:06 -0600https://ask.sagemath.org/question/41419/How to write the given program in sagehttps://ask.sagemath.org/question/41274/how-to-write-the-given-program-in-sage/I am new to sage. I have learned the basics of sage programming from various online notes.
I am interested to apply sage in linear algebra and graph theory.
My problem is I want to draw a graph as follows:
Vertices : Subspaces of a vector space of dimension $n$.
Edges: $V_1V_2\iff V_1 \subset V_2$ or $V_2\subset V_1$.
Please don't give me the solution.
Please help me how to write it step by step or give some resources from where I can find this.
CaptchaMon, 26 Feb 2018 21:53:00 -0600https://ask.sagemath.org/question/41274/Import error with pydotplushttps://ask.sagemath.org/question/41078/import-error-with-pydotplus/ Hello,
I am running Sagemath 7.3 on Linux. I would like to export a graph using the export function of the graph, but I get the error
`
ImportError: No module named pydotplus`
The python module pydotplus was already installed with `pip install pydotplus`
I cannot find any help regarding this issue. Any suggestion?
Thank you in advance for your helpluno_TMon, 12 Feb 2018 07:55:11 -0600https://ask.sagemath.org/question/41078/shortest pathhttps://ask.sagemath.org/question/40267/shortest-path/Hi, I wanna find the best route by minimizing the cost form 4a to 1a,
I write this code in Cocalc
G = Graph({"1a": {"2a": 521916, "22a": 182390, "23a": 144448, "44a": 1199260, "101a": 73200},
"23a": {"24a": 200324,"101a": 193980},
"2a": {"3a": 193980},
"3a": {"4a": 176900},
"4a" : {"5a":78080},
"5a" : {"6a":599386},
"6a" : {"7a":633180, "30a":845582},
"7a":{"8a":293532},
"8a":{"9a":197030, "32a":562420},
"9a":{"10a":97600},
"10a":{"17a":154940},
"9a":{"16a":342820},
"16a":{"17a":354898,"18a":164578, "15a":309880,"18a":164578},
"15a":{"14a":592920},
"18a":{"19a":147559},
"19a":{"20a":338550},
"20a":{"21a":190930},
"21a":{"7a":26230},
"32a":{"31a":207400},
"11a":{"12a":498980},
"33a":{"34a":378200},
"34a":{"35a":196176},
"30a":{"28a":200080},
"28a":{"29a":390888},
"29a":{"25a":462136},
"25a":{"26a":536800},
"2a":{"25a":183000},
"26a":{"27a":694790},
"27a":{"28a":747128},
"27a":{"41a":317200},
"41a":{"42a":451400},
"42a":{"12a":85400},
"41a":{"40a":660020},
"42a":{"44a":500566},
"12a":{"64a":231800},
"64a":{"65a":505568},
"45a":{"46a":581696},
"46a":{"47a":819352},
"47a":{"48a":486292},
"48a":{"49a":466406},
"49a":{"50a":292800},
"50a":{"51a":744200},
"51a":{"52a":256200},
"52a":{"53a":573400},
"52a":{"54a":744200},
"54a":{"55a":195200},
"55a":{"56a":689300},
"55a":{"62a":366000},
"62a":{"63a":793000},
"56a":{"57a":183000},
"57a":{"58a":149084},
"58a":{"59a":390400},
"59a":{"60a":265960},
"60a":{"61a":378810},
"66a":{"67a":504470},
"67a":{"68a":245830},
"68a":{"69a":213500},
"69a":{"70a":256200},
"67a":{"71a":833138},
"71a":{"72a":686860},
"72a":{"73a":732000},
"73a":{"74a":305000},
"74a":{"75a":207400},
"72a":{"76a":479460},
"76a":{"77a":183000},
"77a":{"78a":512400},
"71a":{"84a":131760},
"84a":{"83a":466040},
"83a":{"85a":187880},
"83a":{"82a":453840},
"82a":{"81a":376980},
"81a":{"80a":451400},
"80a":{"79a":368074},
"85a":{"86a":543266},
"86a":{"87a":513742},
"87a":{"88a":699426},
"88a":{"89a":685030},
"89a":{"90a":386130},
"89a":{"91a":451400},
"91a":{"92a":669170},
"92a":{"93a":313784},
"93a":{"94a":12.2},
"93a":{"95a":548024},
"95a":{"96a":45140},
"86a":{"97a":319640},
"36a":{"37a":31720},
"98a":{"99a":488000},
"98a":{"39a":644770},
"39a":{"43a":435906},
"49a":{"57a":399916},
"23a":{"101a":193980},
"101a":{"1a":73200},
"2a":{"25a":183000},
"23b":{"101b":82200},
"101b":{"25b":373800},
"25b":{"3b":63000},
"3b":{"4b":245400},
"4b":{"6b":202800},
"6b":{"7b":180000},
"7b":{"8b":220800},
"8b":{"13b":246000},
"23a":{"23b":250000},
"101b":{"101a":250000},
"25b":{"25a":250000},
"3b":{"3a":250000},
"4b":{"4a":250000},
"6b":{"6a":250000},
"7b":{"7a":250000},
"8b":{"8a":250000},
"13b":{"13a":250000}})
G.plot(edge_labels=True).show() # long time
G.shortest_path("4a", "1a", by_weight=True)
<change> I mean I wrote G.shortest_path("4a", "1a", by_weight=True) instead of G.shortest_path("3a", "2a", by_weight=True)
but it gives me 4a,5a,6a,30a, 28a, 29a, 25a, 2a,1a (which is not the best route)
because i try to manually calculate and there's a better route which is 4a, 3a, 2a, 1a
so, why this g.shortest_path doesn't give me the shortest one?
n btw what's the command to print/show the total cost of the chosen shortest path?
Thanks, Astra
Ps. I'm new to sagemathAstra BeThu, 21 Dec 2017 03:01:47 -0600https://ask.sagemath.org/question/40267/find embedded subgraphshttps://ask.sagemath.org/question/40140/find-embedded-subgraphs/Hi there,
is there a method to find all embedded copies of a graph in another graph, e.g. given two graphs H and G I want something like:
G = graphs.RandomGNP(10,.3) #some graph
H = Graph({1:[1,2], 2:[1,2]}) #some other graph
list = G.find_subgraphs(H, homeomorphic=False/True)
Where the elements list are all the subgraphs in G which are isomorphic/homeomorphic to H.
If this is too much to ask for, there should be at least a method to return all cycles in G (i.e. closed paths in G with each vertex at most once). Since there exists the Hamiltonian cycle method this one should exist too.
PS: In my case the graph has multiedges (and loops, but we can ignore this here).ctstWed, 13 Dec 2017 09:13:56 -0600https://ask.sagemath.org/question/40140/Plotting a frequency chart from a set of valueshttps://ask.sagemath.org/question/39677/plotting-a-frequency-chart-from-a-set-of-values/Hello,
I have got a list of results from my function already. And now, I need to visualise this information and plot a chart of how many times each particular value is repeated in a list. I know how to do a histogram, but it shows intervals of values, but not specific values. I need to access all the values afterwards as well and be able to work with them.
----------
I have found also that I can count values using a command "count"
`list.count()` if it is necessary to do it like this in my problem.
I'd like to ask what is the code for such frequency chart (or plot of points)? And how do I need to define my variables?
Would be much appreciated if someone could help in any way. Thank you very much.
XeniaXeniaMon, 20 Nov 2017 12:12:52 -0600https://ask.sagemath.org/question/39677/