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

Added chodal_simplicial_vertex function #1861

Closed

Conversation

hector1618
Copy link

I have added small function to get simplicial vertex for chordal graph.

Main objective is to get some preliminary code review before further work.

@dschult
Copy link
Member

dschult commented Nov 24, 2015

The main loop uses nx.all_neighbors, but you have restricted the routine to undirected graphs so might be better to use G[node] to get neighbors. So the main loop could become:

for node in G:
     if _is_complete_graph(G.subgraph(G[node])):
        return node

Note also that some "corner" cases may exist.. I think isolated nodes might be found by this routine. Maybe that is OK... I don't know enough about the applications. Similarly, nodes of degree 1 would qualify.

You should spell check the doc_string.
The tests could be expanded to include making sure the error(NetworkXError) behavior is correct.

Thanks!

@@ -242,6 +243,48 @@ def chordal_graph_treewidth(G):
max_clique = max(max_clique,len(clique))
return max_clique - 1

def chordal_simplicial_vertex(G):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the decorator @not_implemnted_for('directed','multigraph') here. This will raise NetworkXNotImplemented, which seems much more relevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, if this could be added to is_chordal function instead.

@hector1618
Copy link
Author

Thank you for reply @dschult and @SanketDG.

Vertices with degree at most one can be considered as simplicial vertices. These definition will be useful while creating the pre-vertex ordering for Chordal graphs (both for disconnected and connected).

I second with @SanketDG that Not_implemented_for should be for is_chordal if we are not planning to handle directed chordal graph soon.

@@ -9,6 +9,7 @@
import networkx as nx
import random
import sys
from ...utils import not_implemented_for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use from networkx.utils import not_implemented_for instead.

@hagberg
Copy link
Member

hagberg commented Apr 16, 2016

Needs updating to address comments.

@hagberg hagberg modified the milestones: networkx-future, networkx-2.0 Apr 16, 2016
@hagberg hagberg marked this pull request as draft June 25, 2020 21:01
Base automatically changed from master to main March 4, 2021 18:20
@MridulS
Copy link
Member

MridulS commented Nov 8, 2023

This hasn't been updated in a while, I'll go ahead and close this PR. Thanks for your work on this @hector1618 !

@MridulS MridulS closed this Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

6 participants