def mergeGraphs(targetGraph, addedGraph, incrementedNodeVal = 'count', incrementedEdgeVal = 'weight'):
    for addedNode, attribs in addedGraph.nodes(data = True):
        if incrementedNodeVal:
            try:
                targetGraph.node[addedNode][incrementedNodeVal] += attribs[incrementedNodeVal]
            except KeyError:
                targetGraph.add_node(addedNode, **attribs)
        else:
            if not targetGraph.has_node(addedNode):
                targetGraph.add_node(addedNode, **attribs)
    for edgeNode1, edgeNode2, attribs in addedGraph.edges(data = True):
        if incrementedEdgeVal:
            try:
                targetGraph.edges[edgeNode1, edgeNode2][incrementedEdgeVal] += attribs[incrementedEdgeVal]
            except KeyError:
                targetGraph.add_edge(edgeNode1, edgeNode2, **attribs)
        else:
            if not targetGraph.Graph.has_edge(edgeNode1, edgeNode2):
                targetGraph.add_edge(edgeNode1, edgeNode2, **attribs)