-
Notifications
You must be signed in to change notification settings - Fork 200
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
[BUG] CGNN error: module 'networkx' has no attribute 'adj_matrix' #163
Comments
same here |
The problem is that the You can go to the cdt.causality.graph.CGNN, and change the function def hill_climbing(data, graph, **kwargs):
"""Hill Climbing optimization: a greedy exploration algorithm."""
if isinstance(data, th.utils.data.Dataset):
nodelist = data.get_names()
elif isinstance(data, pd.DataFrame):
nodelist = list(data.columns)
else:
raise TypeError('Data type not understood')
# tested_candidates = [nx.adj_matrix(graph, nodelist=nodelist, weight=None)]
tested_candidates = [nx.adjacency_matrix(graph, nodelist=nodelist, weight=None)]
best_score = parallel_graph_evaluation(data,
tested_candidates[0].todense(),
** kwargs)
best_candidate = graph
can_improve = True
while can_improve:
can_improve = False
for (i, j) in best_candidate.edges():
test_graph = deepcopy(best_candidate)
test_graph.add_edge(j, i, weight=test_graph[i][j]['weight'])
test_graph.remove_edge(i, j)
# tadjmat = nx.adj_matrix(test_graph, nodelist=nodelist, weight=None)
tadjmat = nx.adjacency_matrix(test_graph, nodelist=nodelist, weight=None)
if (nx.is_directed_acyclic_graph(test_graph) and not any([(tadjmat != cand).nnz ==
0 for cand in tested_candidates])):
tested_candidates.append(tadjmat)
score = parallel_graph_evaluation(data, tadjmat.todense(),
**kwargs)
if score < best_score:
can_improve = True
best_candidate = test_graph
best_score = score
break
return best_candidate Then it should be work. |
Hello, I am trying to run CGNN model based on an undirected graph, using the "orient_directed_graph" function.
I am using the exact same codes presented in this example:
https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/examples/example_cgnn.ipynb
Describe the bug
But whenever, I run the CGNN codes, I obtain this error, which indicates that the 'networkx' library has no attribute 'adj_matrix'.
I think it is maybe because the function 'adj_matrix' was deprecated in the 'networkx' library.
Below is the versions of my python and related libraries.
I am running my codes on GPUs.
The text was updated successfully, but these errors were encountered: