MolecularGraph.jl icon indicating copy to clipboard operation
MolecularGraph.jl copied to clipboard

Layout mechanism in drawing

Open mojaie opened this issue 5 years ago • 2 comments

  • Position of atom/bond indices
  • Position of charges and electrons
  • Merge molecules
  • Add annotation text (descriptors, functional groups)

mojaie avatar Aug 02 '20 13:08 mojaie

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 avatar Dec 01 '20 20:12 timholy

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.

timholy avatar Dec 01 '20 20:12 timholy