Open c703ac91-1c31-4f3a-abb2-47af3ac2705d opened 7 years ago
Description changed:
---
+++
@@ -1 +1 @@
-
+A TransversalMatroid class that is a child of BasisExchangeMatroid, using a bipartite graph for data.
The way I have it currently set up, it builds a digraph from the data after taking a matching and orienting it opposite of everything else, and this is used for finding alternating paths and enabling the basis exchange. I'll upload it as soon as I get git-trac working again.
New commits:
1cd8653 | Starting a transversal matroid class |
Commit: 1cd8653
Branch pushed to git repo; I updated commit sha1. New commits:
cac3e05 | writing out internal bipartite graph; added _minor override |
This is behaving in ways I don't understand. If I add an isolated vertex to the ground set side of the bipartite graph, that should be a loop, but right now it will think that the element is in parallel with something, even though __is_exchange_pair()
is always False
no matter what you check it with.
In exploring this, I discovered a more serious error.
sage: G = Graph([('a', 'b'), ('b', 'c')])
sage: G.add_vertex('d')
sage: from sage.matroids.transversal_matroid import TransversalMatroid
sage: M = TransversalMatroid(G, groundset = ['a', 'c', 'd'])
sage: M.loops()
After a long traceback, we get this error:
ValueError: vertex '1' is not in the (di)graph
Why would it be looking for a vertex '1'?
The BasisExchangeMatroid class does an extra round of translation: elements get changed into integers through pack and unpack. This ensures elements correspond directly to bits in a bitset.
Branch pushed to git repo; I updated commit sha1. New commits:
faba993 | We now know what loops are |
I found a hint in the BasisMatroid class that x
refers to the element e = self._E[x]
. I guess my previous examples worked because my ground set was in a natural bijection with range(n)
. Maybe I should rewrite it later using bitset commands, but for now I'm just glad it works.
Branch pushed to git repo; I updated commit sha1. New commits:
9649227 | Documentation, tests, other fixes |
I think it's complete enough to be reviewed now. It lacks a method to give a minimal or maximal presentation, but I think getting a set system to work as input through the constructor is a priority, and that belongs in another ticket.
Dependencies: #23139
Looks like it timed out as I was pushing an update. It's all there now.
Also, this will almost certainly conflict with #23139 in a couple of places like unpickling.pyx.
Branch pushed to git repo; I updated commit sha1. New commits:
955bc16 | forgot author stuff |
Author: Zachary Gershkoff
Actually, let me think about this a little more before it's reviewed.
I can't find a clean algorithmic way to get a minimal presentation, but with reduce_presentation()
, we at least get a presentation where the number of sets equals the rank.
It should be a little faster now that the basis exchange computations are done in NetworkX.
Also, the reason I let it assume that the larger side of a BipartiteGraph
is the ground set is that there's no method to switch the sides, so it would be inefficient to have the constructor take a bipartite graph as input, build a new one, and sent it to __init__()
. I could rewrite __init__()
to take a set system instead of a graph, but that should be done in a ticket where these are added to the constructor.
Branch pushed to git repo; I updated commit sha1. New commits:
1ae7e8a | added note in documentation about ground set |
I think it's ready now.
I can't fix it now because I'm upgrading sage so maybe the documentation will build, but patchbot says there are a couple of problems. I don't know what "coverage" is (maybe I just need to rebase) but it looks like there's a python3 compatibility problem because iteritems()
is deprecated for dictionaries, which should mean it won't work for the Counter
either.
"Coverage" is checking to see if the code has sufficient doctests. I'm not seeing any methods that are missing examples/tests, but maybe since you're defining a class you need to run some sort of testsuite to make sure it's done right?
For python3 compatibility, I think you just need to change d.iteritems() -> iter(d.items())
.
A TransversalMatroid class that is a child of BasisExchangeMatroid, using a bipartite graph for data.
Depends on #23139 Depends on #25065
CC: @sagetrac-Stefan @sagetrac-Rudi @sagetrac-yomcat @sagetrac-zgershkoff
Component: matroid theory
Author: Zachary Gershkoff
Branch/Commit: public/matroids/transversal_matroids-23536 @
c228986
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/23536