ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 02 May 2015 17:25:28 -0500How can I get Sage to go over all possible maps between two sets?http://ask.sagemath.org/question/26705/how-can-i-get-sage-to-go-over-all-possible-maps-between-two-sets/ What I want to do is this : Say I take a graph $K_{n,n}$ and choose an ordering for each edge arbitrarily - say denote each edge as $(i,j)$ where $i$ is in the left partition and $j$ is in the right partition. I have a set of matrices $A = { A_1, A_2,...,A_k \}$. I want to iterate over all possible ways in which one could have assigned an A matrix to an edge of this graph.
- How does one do that? (..apart from writing a massive sequence of nested loops!..)
phoenixSat, 02 May 2015 17:25:28 -0500http://ask.sagemath.org/question/26705/Adding a loop to graphhttp://ask.sagemath.org/question/9413/adding-a-loop-to-graph/I have a for loop that adds edges to a graph `g`, but I also want the graph to add loops. How can I do this, for a general graph whose structure I do not know (that is, I want to add the loop to a graph, rather than make a new graph)?
I've tried using the `g.add_edge(1,1)` function, but that doesn't work, i.e. no loop is added. I also tried using `g.add_edge` three times, then `g.merge_vertices` to contract the cycle to a loop, but also to no avail. Sage justs simplifies the graph.
Any approach to this would be appreciated, direct or indirect. jlvThu, 11 Oct 2012 03:30:53 -0500http://ask.sagemath.org/question/9413/