Digraphs icon indicating copy to clipboard operation
Digraphs copied to clipboard

Add a function to create unit weight digraphs or make edge weight functions work with unweighted digraphs

Open reiniscirpons opened this issue 4 months ago • 5 comments

It would be nice if there was a function to create an edge-weighted digraph from a given digraph by assigning each edge a weight of 1, e.g. UnitEdgeWeightedDigraph(D). Currently if you want to do this you need to call something like

gap> EdgeWeightedDigraph(D, List(DigraphVertices(D), x -> ListWithIdenticalEntries(OutDegreeOfVertex(D, x), 1)));

which is a bit cumbersome, especially when using the gap REPL. The reason for having such a function is that it is sometimes useful to call weighted digraph functions such as DigraphMaximumFlow on unweighted digraphs by assuming each edge has unit weight.

An alternative would be to modify the weighted graph functions to also accept unweighted digraphs as input, and automatically add unit weights to them if they are unweighted, but this might be a bit harder to maintain.

reiniscirpons avatar Sep 30 '25 14:09 reiniscirpons

@mtorpey any thought on this, specifically on letting weighted digraph functions accept unweighted digraphs?

reiniscirpons avatar Sep 30 '25 14:09 reiniscirpons

I quite like a special UnitEdgeWeightedDigraph(D) function! This would be only a small extra effort on users' part if they want to use the edge-weighted digraph functions with unit weights, and would avoid confusion.

mtorpey avatar Sep 30 '25 15:09 mtorpey

Definitely a good newcomer issue too.

mtorpey avatar Sep 30 '25 15:09 mtorpey

Perhaps one for @coraaked

mtorpey avatar Oct 01 '25 14:10 mtorpey

Perhaps one for @coraaked

Having a look at it now!

coraaked avatar Oct 01 '25 16:10 coraaked