'Tests that the :func:`networkx.from_numpy_matrix` function
interprets integer weights as the number of parallel edges when
creating a multigraph.'

def test_from_numpy_matrix_parallel_edges(self):

    A = np.matrix([[1, 1], [1, 2]])
    expected = nx.DiGraph()
    edges = [(0, 0), (0, 1), (1, 0)]
    expected.add_weighted_edges_from([(u, v, 1) for (u, v) in edges])
    expected.add_edge(1, 1, weight=2)
    actual = nx.from_numpy_matrix(A, parallel_edges=True, create_using=nx.DiGraph())
    assert_graphs_equal(actual, expected)
    actual = nx.from_numpy_matrix(A, parallel_edges=False, create_using=nx.DiGraph())
    assert_graphs_equal(actual, expected)
    edges = [(0, 0), (0, 1), (1, 0), (1, 1), (1, 1)]
    expected = nx.MultiDiGraph()
    expected.add_weighted_edges_from([(u, v, 1) for (u, v) in edges])
    actual = nx.from_numpy_matrix(A, parallel_edges=True, create_using=nx.MultiDiGraph())
    assert_graphs_equal(actual, expected)
    expected = nx.MultiDiGraph()
    expected.add_edges_from(set(edges), weight=1)
    expected[1][1][0]['weight'] = 2
    actual = nx.from_numpy_matrix(A, parallel_edges=False, create_using=nx.MultiDiGraph())
    assert_graphs_equal(actual, expected)
