Coder Social home page Coder Social logo

Comments (4)

gdalle avatar gdalle commented on July 17, 2024 1

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.

nsajko avatar nsajko commented on July 17, 2024

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.

nsajko avatar nsajko commented on July 17, 2024

Not sure how to handle symmetric relations, perhaps there should be another function like from_finite_symmetric_relation?

from graphs.jl.

nsajko avatar nsajko commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.