mojaie / MolecularGraph.jl

Graph-based molecule modeling toolkit for cheminformatics
MIT License
192 stars 28 forks source link

Layout mechanism in drawing #28

Open mojaie opened 3 years ago

mojaie commented 3 years ago
timholy commented 3 years ago

One thought I've had here is to interface with GraphPlot. Currently it requires LightGraphs but perhaps one could generalize it. One of the easiest ways might be to export an adjacency matrix like

struct AdjacencyMatrix{G<:AbstractGraph} <: AbstractMatrix{Bool}
    g::G
end

Base.size(A::AdjacencyMatrix) = (n = nodecount(A.g); return (n, n))

Base.getindex(A::AdjacencyMatrix, i::Int, j::Int) = hasedge(A.g, i, j)

and then modify GraphPlot to accept an adjacency matrix. You'd also need to supply node labels, but the package already looks like it supports that. Trickier would be double & triple bonds, but again that could probably be implemented there.

timholy commented 3 years ago

Now that I think about it, for chemical graphs it may not make a lot of sense, because there are bond-angle constraints that it would be nice to respect.

This idea came up for me more in the context of #42, trying to understand the nature of the graph (by visualization) constructed by that call to plaingraph. Might be useful for the general-purpose MolecularGraph.Graph, but perhaps not for actual molecules.