Comments (13)
from graphblas.
Practically, I have run an s-t max-flow algorithm on a graph and produced the residual graph R, and I am trying to efficiently find the min-cut.
Performing a breadth-first search from the source s in R, I can determine all vertices reachable from the source, the s-set.
A picture of an example graph G. The marked edges are the min-cut edges I want to extract. Those, along with other edges used at full capacity in the max-flow algorithm would not be in R, which is why a breadth-first search starting from the source-vertex on the left would produce s.
In order to find the vertices at the t-side of the cut, I can perform a single VxM operation t<s'> = s * G, where G is the original graph input. What I think I am doing here is using the aquired s as frontier and traversing outward from it into the graph, but ignoring any vertices already present in s by using the mask.
In this last VxM operation, the "traversed edges" are the ones I wan to extract, which is why I asked if there is some way of inspecting which matrix-values are actually used in a VxM operation.
My current method for extracting the min-cut is simply iterating over all the vertex pairs (i,j), i in s, j in t and seeing if there is an edge (i,j) in the graph. Becaue this method has a time complexity of O(n^2), it doesn't quite cut it.
from graphblas.
call the first node on the left A and the last node on the right B.
on the s side, do the multiplication forward twice to find all 2 degrees nodes from A.
then on the t side when you do the multiplication backwards from B (aka by the transpose of the edge matrix), simply mask the output of that multiplication by the edges reached in the 1st operation.
this gives you the intersection, aka t.
from graphblas.
from graphblas.
@DrTimothyAldenDavis i think the point is that they start with the 2 distant nodes, and the assumption there exists one or more 3rd degree mappings between them, and want to extract all nodes that participate in that mapping. (from left to right).
from graphblas.
from graphblas.
Sorry for being unclear. What I want is indeed the (1) alternative you presented here, a list of 6 edges as (i,j,x) triplets.
To use GrB_extract, it seems I need the (i,j) tuples already available in the form of row_indices and col_indices vectors. The problem for me then is constructing these two vectors.
from graphblas.
from graphblas.
from graphblas.
Got it to work. Below I am assuming s contains only the vertices adjacent to the cut, not the somewhat confusing s-set I drew earlier. The process I ended up going for:
- GrB_extractTuples on s and t
- GrB_extract on A using the indices from 1., constructing a new matrix C
- GrB_extractTuples on C
- Translate the indices in 3. back to indices in the original matrix A by re-using the indices from 1.
Note: This is just a sequential for-loop over the arrays - Construct a new matrix using the values from 3. and the translated indices from 4.
Ideally there could have been a way to use s and t to perform a kind of extract/filter/mask on the orignal matrix while keeping its structure intact, which would have reduced this process to a single step. But, this worked, and saved me a whole lot of time compared to calling GrB_extractElement n^2 times 😅
from graphblas.
from graphblas.
When you say assign is a powerful (and I assume heavy) operation, does that mean other GraphBLAS functions might be faster even if assign is the most "intuitive"?
Specifially, in one part of my program I need to extract the elements in a matrix corresponding to a boolean mask. I can either do this using an um-masked element-wise multiplication or a masked assign.
Similarly when assigning one value to all the exisiting elements in a matrix, I can either perform a masked assign or an un-masked apply (by providing a unary function that always returns the same value).
In these cases, assign seems most intuitive, but I am unsure if it implies the best performance.
from graphblas.
from graphblas.
Related Issues (20)
- GxB sort with smaller (or larger) output objects
- cpu_features: Build error for MinGW HOT 13
- Size of Static Library HOT 16
- Link error with Intel igx and Ninja generator on Windows HOT 9
- Optimisation report causing build failure when using Intel oneAPI HOT 2
- nvals weirdness with 8.0.0 for max-sized Vector HOT 6
- Where is `GxB_Context_error`? HOT 3
- Why was `nthreads` and `chunks` remove from the descriptor? HOT 5
- dynamic connectivity in the language of graphblas HOT 1
- Fastest Way to Exfiltrate a Matrix HOT 3
- no JIT kernels produced? HOT 3
- Modify CMake options to build without bundled libraries HOT 1
- Sublinear Performance with n Threads HOT 6
- [BUG]: Incorrect result(!) in vector-matrix multiply with accumulation in versions 8.0.2 and 8.2.0 HOT 13
- Allow enabling and disabling JIT for operators and types with get/set HOT 1
- Monoid Creation with Scalar HOT 1
- Excess allocation in dense apply HOT 2
- Proposal: GxB_CASTOP HOT 3
- `GrB_get` instead of fprint HOT 1
- make static not working as expected in 9.0.1 release HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphblas.