Number of Acyclic Alkane Isomers - Python Version
In the previous post I have outlined the method of calculating the number of open-chain alkane isomers in R. Since the calculation times for higher alkanes were impractically long, I have loosely translated, with minor changes, my program into python. The code follows below. As for the results - no substantial improvement could be observed. My next attempt would be in Java. import networkx as nx import matplotlib.pyplot as plt import copy from datetime import datetime def addc(graph): n = graph.number_of_nodes() list = [] for i in range(n): if graph.degree[i] < 4: graph_c = copy.deepcopy(graph) graph_c.add_node(n) graph_c.add_edge(i, n) res = [nx.is_isomorphic(gr, graph_c) for gr in list] if not any(res): list.append(graph_c) return list def comblist(list1, list2): list_out = copy.deepcopy(list1) for gr2 in list2: res = [nx.is_isomorphic(gr2,gr1)