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

[BUG] orient_graph removes some of the edges #146

Open
chhajer-rajul opened this issue Oct 10, 2022 · 0 comments
Open

[BUG] orient_graph removes some of the edges #146

chhajer-rajul opened this issue Oct 10, 2022 · 0 comments

Comments

@chhajer-rajul
Copy link

chhajer-rajul commented Oct 10, 2022

Describe the bug
While applying Orient graph to orient a CPDAG, the procedure removes some of the edges present in the graph. I specifically used ANM object to call this procedure.

def orient_graph(self, df_data, graph, printout=None, **kwargs):
       
        if isinstance(graph, nx.DiGraph):
            edges = [a for a in list(graph.edges()) if (a[1], a[0]) in list(graph.edges())]
            oriented_edges = [a for a in list(graph.edges()) if (a[1], a[0]) not in list(graph.edges())]
       Output of edges variable: 

[('V2', 'V7'),
('V3', 'V7'),
('V7', 'V2'),
('V7', 'V3'),
('V7', 'V8'),
('V8', 'V7'),
('V8', 'V9'),
('V9', 'V8')]

// below code deletes the edges from the edge list which later would be used for orientation


            for a in edges:
                if (a[1], a[0]) in list(graph.edges()):
                    edges.remove(a)
            output = nx.DiGraph()
            for i in oriented_edges:
                output.add_edge(*i)

       Output of edges variable: 

[('V7', 'V3'),
('V9', 'V8')]

Not Sure why the algorithm deleting some of the un-oriented edges

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