Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with the distance matrices #6

Open
pandadada123 opened this issue Apr 28, 2023 · 0 comments
Open

Problems with the distance matrices #6

pandadada123 opened this issue Apr 28, 2023 · 0 comments

Comments

@pandadada123
Copy link

Thanks for this great package for FGW!

But there may be some bugs with the distance matrices C1 and C2. I tried a graph in the dataset BZR, and some entries in C1 seem to be not correct.

Here are the codes.

import numpy as np
import os,sys
sys.path.append(os.path.realpath('../lib'))

from graph import graph_colors,draw_rel,draw_transp,Graph,wl_labeling
from ot_distances import Fused_Gromov_Wasserstein_distance,Wasserstein_distance
import copy
from data_loader import load_local_data,histog,build_noisy_circular_graph
import matplotlib.pyplot as plt
import networkx as nx
import ot

dataset_n='bzr'
path='../data/'
X,label=load_local_data(path,dataset_n,wl=0) 
G1=X[0]
g1=G1.nx_graph

G2 = copy.deepcopy(G1)

vmin=-5
vmax=20 # the range of color

plt.figure(figsize=(8,5))
draw_rel(g1,vmin=vmin,vmax=vmax,with_labels=True,draw=False)

dgw=Fused_Gromov_Wasserstein_distance(alpha=1,features_metric='hamming_dist',method='shortest_path').graph_d(G1,G2)

The graph G1 I get is
Figure_1

I also slightly changed the following two lines to draw this graph properly.

val_map[k]=cpick.to_rgba(v)

nx.draw(G,pos,with_labels=True,labels=nx.get_node_attributes(G,'attr_name'),node_color = colors)

Change them to:

val_map[k]=cpick.to_rgba(sum(pow(np.array(v),2)))

and

 nx.draw_networkx(G,pos,node_color = colors)

The distance matrix (30 * 30) of this graph can be checked. The first line of it is:

0	1	1	1	2	2	3	3	2	4	3	2	5	5	5	4	6	6	5	4	6	6	7	7	8	8	7	9	8	7

where the third entry "1" indicates the shortest path length between node 1 and node 3, but we can see from the graph that this length should be "2".

I would appreciate any comments you may have!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant