Пример #1
0
    def copy(self):
        """
        """
        newCG = ChemicalGraph()
        newCG = Graph.copy(self)

        return newCG
Пример #2
0
def create_true_graph_copy():
    '''
    - <Graph>.copy() returns a true copy of the original graph
        - == operator for graph objects is useless, or perhaps __eq__ isn't implemented so it falls back to "is" behavior
    - This is NOT what I want if I don't want to copy attributes
    '''
    g = Graph([(1, 5), (5, 5)])
    g.add_node(6)
    g.graph['pie'] = 'apple'
    g.node[1]['pet'] = 'fish'
    g.edge[5][5]['sound'] = 'clink'
    h = g.copy()
    print(h.nodes())  # [1, 5, 6]
    print(h.edges())  # [(1, 5), (5, 5)]
    print(h.graph)  # {'pie': 'apple'}
    print(h.node)  # {1: {'pet': 'fish'}, 5: {}, 6: {}}
    print(h.edge)  # {1: {5: {}}, 5: {1: {}, 5: {'sound': 'clink'}}, 6: {}}
    print(h is g)  # False
    print(h == g)  # False