Skip to content

cafe.metric.metric_topology

cafe.metric.metric_topology

calculate_isomorphic(net1, net2)

Judge if two milestone network are isomorphic

Parameters:

Name Type Description Default
net1 DataFrame

reference milestone network

required
net2 DataFrame

predict milestone network

required

Returns:

Name Type Description
int

0 is not isomorphic, 1 is isomorphic

Source code in cafe/metric/metric_topology.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def calculate_isomorphic(net1: pd.DataFrame, net2: pd.DataFrame):
    """Judge if two milestone network are  isomorphic

    Args:
        net1 (pd.DataFrame): reference milestone network
        net2 (pd.DataFrame): predict milestone network

    Returns:
        int: 0 is not isomorphic, 1 is isomorphic
    """
    graph1 = nx.from_pandas_edgelist(net1, source="from", target="to")
    graph2 = nx.from_pandas_edgelist(net2, source="from", target="to")
    if nx.is_isomorphic(graph1, graph2):
        return 1
    else:
        return 0