Comments (4)
Thank you for the suggestion!
I feel like that is easily achieved without adding custom logic to Graphs.jl:
julia> using Graphs
julia> julia> predicate((i, j)) = (i - j) % 3 == 0
predicate (generic function with 1 methods)
julia> edge_iter = Iterators.map(Edge, Iterators.filter(predicate, Iterators.product(1:10, 1:10)));
julia> g = SimpleGraphFromIterator(edge_iter)
{10, 22} undirected simple Int64 graph
julia> adjacency_matrix(g)
10×10 SparseArrays.SparseMatrixCSC{Int64, Int64} with 34 stored entries:
2 ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ 1
⋅ 2 ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅
⋅ ⋅ 2 ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅
1 ⋅ ⋅ 2 ⋅ ⋅ 1 ⋅ ⋅ 1
⋅ 1 ⋅ ⋅ 2 ⋅ ⋅ 1 ⋅ ⋅
⋅ ⋅ 1 ⋅ ⋅ 2 ⋅ ⋅ 1 ⋅
1 ⋅ ⋅ 1 ⋅ ⋅ 2 ⋅ ⋅ 1
⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ 2 ⋅ ⋅
⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ 2 ⋅
1 ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ 2
from graphs.jl.
To be clear, I'm proposing the addition of a function like so:
"""
from_finite_binary_relation(predicate, G::Type, finite_iterator)::G
Construct a graph of type `G` from a binary relation on `finite_iterator` defined by the predicate `predicate`.
"""
function from_finite_binary_relation end
from graphs.jl.
Not sure how to handle symmetric relations, perhaps there should be another function like from_finite_symmetric_relation
?
from graphs.jl.
My motivation for this feature request is that I want an easy way to visualize partial order relations (like Julia's subtyping relation). It'd be nice if I could construct a SimpleDiGraph
from my relation, then use transitivereduction
to compute the covering relation/Hasse diagram.
from graphs.jl.
Related Issues (20)
- Question regarding `non_backtracking_matrix` function's return type HOT 1
- Tests failing on nightly
- Fix source of randomness in doctests HOT 3
- Functions for Edge Adjacency HOT 1
- [BUG] `StackOverflowError` in `Graphs.Experimental.has_isomorph` HOT 5
- Inconsistent dependency on ArnoldiMethod HOT 8
- [BUG] edges(::SimpleGraph) is broken in 1.10.0 HOT 2
- [BUG] `steiner_tree` fails if only one terminal vertex is passed HOT 1
- [BUG] `merge_vertices` returns an undirected graph, even if the input is directed.
- Define `rem_edge!(::AbstractGraph, ::Pair)` HOT 1
- `SimpleGraph(::Base.OneTo)` HOT 1
- Incorrect documentation for `dfs_tree`. HOT 2
- dorogovtsev_mendes graph generator is running in O(n^2) HOT 1
- Add tests on release candidate when it comes out
- [OPTIM] perm_greedy_color (and thus all coloring algorithms) is running in O(n^2) instead of O(n) HOT 1
- [BUG] Extra vertices in Steiner tree HOT 1
- [FR] a function to efficiently check whether a graph is acyclic HOT 1
- Hope to implement of infomap HOT 1
- [BUG] Compatibility issue when used alongside GraphPlot HOT 2
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 graphs.jl.