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

Adding average_path_length as the graph descriptor function #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Albert-Sharma
Copy link
Collaborator

No description provided.

Albert-Sharma and others added 13 commits June 6, 2023 13:33
1. The programme first turns the edge weights into a NumPy array before checking for a certain form. We may directly interact with the graph.es[attribute] object and do the shape check on it rather than immediately converting to an array.

2.To deal with a particular scenario when there is only one edge in the graph, the code employs a conditional check if weights.size!= 1. By treating the single edge case individually and without turning it into a 2D array, this check may be avoided.

3.We may utilize the np.argsort() method to get the indices that will sort the weights array instead of using the sorted() function on the array. When working with huge arrays, this may be more effective.

4.When the graph is huge, the algorithm must generate a subgraph for each weight threshold, which takes time. Alternatively, you may save the indexes of the chosen edges and only ever generate the subgraph once after the loop.
1.calculate_subgraph_average_path_lengths
 This function calculates the average path length for each subgraph in the list of filtration curves. It iterates across the list, creating an igraph for each row (representing a filtering curve). The average path length is calculated for a graph object created using the create_graph_from_filtration_row method. The average route lengths that result are saved in a list.
2. create_graph_from_filtration_row 
This function generates an igraph from a single row of the filtering curve.The related subgraph is represented as a graph object. It takes the information from the row, such as the number of nodes and edge indices, and uses the igraph to generate the graph.Graph generator
The alternate code was not considering the 1D grarhs thus crashing the code.
reduced the n_iterations 10 -> 8. (just for less memory usage)
In this script I tried to execute the average path length graph descriptor function on the unlabeled dataset e.g. MUTAG and got accuracy: 80.61 +- 0.75

The igraph library reads each file path to load the graphs into memory. From the graph objects, the labels of the graphs are taken out and kept in the y list. The average_path_length method of igraph is used to get the average path length for each graph. Following that, the average route lengths are binarized by comparing each value to the lengths and turning it to a value of 0 or 1. 
The binarized data are padded to have a constant length, which produces the filtering curves. The create_curves method returns the filtering curves and the labels (y).
Two additional descriptor functions that successfully operate on the unlabeled dataset (MUTAG) are being uploaded.
Assortativity: accuracy: 79.68 +- 0.99
Between Centrality: accuracy: 85.77 +- 0.54
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

Successfully merging this pull request may close these issues.

2 participants