Correct, I am looking for a rdkit-hidden-option to do it :D

On Wed, Jan 17, 2018 at 5:56 PM, Jason Biggs <jasondbi...@gmail.com> wrote:

> I am a novice when it comes to graph theory, but it seems like what is
> wanted here is the adjacency matrix of the corresponding line graph (
> http://mathworld.wolfram.com/LineGraph.html).
>
> I don't know how to do this in python, but if I use mathematica, it goes
> like this
>
> adjacencyMatrix = {{0, 1, 0, 0, 0}, {1, 0, 1, 1, 0}, {0, 1, 0, 0,
>     0}, {0, 1, 0, 0, 1}, {0, 0, 0, 1, 0}};
>
> graph = AdjacencyGraph[adjacencyMatrix];
> lineGraph = LineGraph[graph];
> AdjacencyMatrix[lineGraph] // MatrixForm
>
> [image: Inline image 1]
>
>
> Jason Biggs
>
>
> On Wed, Jan 17, 2018 at 10:21 AM, Marta Stępniewska-Dziubińska via
> Rdkit-discuss <rdkit-discuss@lists.sourceforge.net> wrote:
>
>> Hi Mario,
>>
>> What exactly do you mean by 'edge matrix'? Are you sure you provided a
>> correct example? If you want to get an adjacency matrix of a molecular
>> graph you can iterate over bonds to get it:
>>
>> from rdkit.Chem import MolFromSmiles
>> import numpy as np
>> m = MolFromSmiles('CC(C)CC')
>> n = m.GetNumAtoms()
>> E = np.zeros((n, n))
>> for b in m.GetBonds():
>>     i = b.GetBeginAtomIdx()
>>     j = b.GetEndAtomIdx()
>>     E[[i,j], [j,i]] = 1
>>
>>
>> Hope this helps,
>> Marta SD
>>
>>
>>
>> 2018-01-17 16:31 GMT+01:00 Mario Lovrić <mario.lovri...@gmail.com>:
>>
>>> Dear all,
>>>
>>> Does any one have an idea how to get an edge matrix (graph theory) out
>>> of Rdkit, I digged deep but didnt find anything.
>>>
>>> F.example for:
>>>
>>> 'CC(C)CC'
>>>
>>>
>>> it would be:
>>>
>>> array([[0, 1, 1, 0],
>>>        [1, 0, 1, 0],
>>>        [1, 1, 0, 1],
>>>        [0, 0, 1, 0]])
>>>
>>> Thanks.
>>>
>>>
>>> --
>>> Mario Lovrić
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> Rdkit-discuss mailing list
>>> Rdkit-discuss@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>
>>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>


-- 
Mario Lovrić
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to