7 | Nested subtree hashing is an embedding algorithm which learns representations for a set of graphs by hashing the Weisfeiler-Lehman subtree patterns. The procedure places graphs in an abstract feature space where graphs with similar structural properties (Weisfehler-Lehman features) are clustered together. Nested subtree hashing has a linear runtime complexity in the number of graphs in the dataset which makes it extremely scalable. At the instance level creating a graph representation has a linear runtime and space complexity in the number of edges. This specific implementation supports multi-core data processing in the feature extraction and hashing phases. (So far this is the only implementation which support multi-core processing in every phase). 8 |
9 |
10 |
11 |
33 | The code takes an input folder with json files. Every file is a graph and files have a numeric index as a name. The json files have two keys. The first key called "edges" corresponds to the edge list of the graph. The second key "features" corresponds to the node features. If the second key is not present the WL machine defaults to use the node degree as a feature. A sample graph dataset from NCI1 is included in the `dataset/` directory. 34 |
35 | ### Options 36 | 37 | Learning of the embedding is handled by the `src/main.py` script which provides the following command line arguments. 38 | 39 | #### Input and output options 40 | 41 | ``` 42 | --input-path STR Input folder. Default is `dataset/`. 43 | --output-path STR Embeddings path. Default is `features/nci1.csv`. 44 | ``` 45 | #### Model options 46 | ``` 47 | --dimensions INT Number of dimensions. Default is 16. 48 | --workers INT Number of workers. Default is 4. 49 | --wl-iterations INT Number of feature extraction recursions. Default is 2. 50 | ``` 51 | 52 | ### Examples 53 | 54 | The following commands learn an embedding of the graphs and writes it to disk. The node representations are ordered by the ID. 55 | 56 | Creating a Nested Subtree Hash embedding of the default dataset with the default hyperparameter settings. Saving the embedding at the default path. 57 | 58 | ``` 59 | python src/main.py 60 | ``` 61 | 62 | Creating an embedding of an other dataset. Saving the output in a custom place. 63 | 64 | ``` 65 | python src/main.py --input-path new_data/ --output-path features/nci2.csv 66 | ``` 67 | 68 | Creating an embedding of the default dataset with 3x32 dimensions as each recursion creates a 32 dimensional multi-scale subspace. 69 | 70 | ``` 71 | python src/main.py --dimensions 32 --wl-iterations 3 72 | ``` 73 | 74 | -------------------------------------------- 75 | 76 | **License** 77 | 78 | - [GNU](https://github.com/benedekrozemberczki/NestedSubtreeHash/blob/master/LICENSE) 79 | 80 | --------------------------------------------- 81 | -------------------------------------------------------------------------------- /dataset/0.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 10], [11, 13], [11, 7], [10, 12], [10, 5], [13, 14], [12, 15], [15, 14], [14, 9], [17, 19], [17, 8], [16, 8], [16, 6], [16, 18], [19, 20], [19, 4], [1, 7], [0, 7], [3, 9], [2, 9], [5, 6]], "features": {"0": "1", "1": "1", "2": "1", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3"}} -------------------------------------------------------------------------------- /dataset/1.json: -------------------------------------------------------------------------------- 1 | {"edges": [[20, 18], [20, 22], [21, 19], [21, 23], [22, 23], [1, 7], [1, 16], [0, 17], [3, 12], [2, 17], [2, 6], [5, 18], [5, 17], [4, 9], [4, 12], [4, 7], [7, 6], [6, 8], [9, 11], [9, 8], [8, 10], [11, 14], [10, 13], [13, 14], [12, 15], [19, 18]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "2", "5": "2", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3"}} -------------------------------------------------------------------------------- /dataset/10.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 19], [24, 26], [25, 27], [25, 23], [26, 27], [20, 21], [20, 22], [20, 7], [21, 17], [22, 18], [23, 19], [1, 16], [0, 12], [3, 7], [2, 7], [5, 12], [5, 4], [4, 8], [6, 13], [6, 16], [9, 8], [8, 10], [8, 11], [13, 12], [13, 14], [15, 18], [15, 14], [15, 17], [16, 19]], "features": {"0": "1", "1": "1", "2": "1", "3": "1", "4": "2", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3"}} -------------------------------------------------------------------------------- /dataset/11.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 9], [11, 15], [10, 3], [10, 12], [10, 4], [13, 3], [13, 5], [12, 5], [12, 14], [15, 1], [15, 2], [14, 0], [14, 6], [16, 4], [16, 6], [3, 7], [7, 8], [9, 8]], "features": {"0": "4", "1": "1", "2": "1", "3": "2", "4": "2", "5": "2", "6": "2", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3"}} -------------------------------------------------------------------------------- /dataset/12.json: -------------------------------------------------------------------------------- 1 | {"edges": [[1, 7], [0, 8], [3, 8], [3, 5], [2, 9], [5, 7], [5, 6], [4, 9], [4, 8], [6, 9]], "features": {"0": "4", "1": "7", "2": "1", "3": "2", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3"}} -------------------------------------------------------------------------------- /dataset/13.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 8], [11, 12], [10, 13], [10, 6], [13, 2], [12, 9], [15, 1], [15, 0], [15, 4], [14, 3], [14, 7], [16, 0], [3, 4], [2, 7], [5, 8], [5, 7], [5, 6], [6, 9]], "features": {"0": "4", "1": "4", "2": "2", "3": "2", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3"}} -------------------------------------------------------------------------------- /dataset/14.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 19], [24, 28], [25, 27], [25, 20], [26, 28], [26, 21], [27, 23], [20, 16], [21, 17], [22, 0], [22, 7], [22, 6], [23, 18], [29, 4], [1, 13], [3, 15], [2, 14], [5, 19], [5, 30], [4, 18], [7, 15], [6, 14], [9, 11], [9, 8], [9, 16], [8, 10], [8, 15], [8, 14], [11, 13], [10, 12], [10, 17], [13, 12], [17, 19], [16, 18]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "1", "5": "1", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3"}} -------------------------------------------------------------------------------- /dataset/15.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 21], [24, 22], [25, 22], [20, 18], [20, 23], [21, 18], [22, 23], [1, 16], [0, 11], [0, 13], [3, 15], [2, 15], [2, 17], [5, 13], [5, 16], [4, 9], [4, 10], [4, 14], [7, 9], [7, 8], [6, 18], [6, 16], [8, 11], [8, 12], [11, 10], [13, 12], [12, 15], [17, 19]], "features": {"0": "4", "1": "4", "2": "1", "3": "1", "4": "2", "5": "2", "6": "2", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3"}} -------------------------------------------------------------------------------- /dataset/16.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 1], [11, 3], [11, 5], [10, 0], [10, 2], [10, 4], [3, 9], [2, 8], [5, 7], [4, 6], [9, 8]], "features": {"0": "4", "1": "4", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3"}} -------------------------------------------------------------------------------- /dataset/17.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 11], [24, 28], [25, 13], [26, 15], [27, 30], [27, 23], [20, 19], [20, 14], [21, 15], [21, 22], [22, 17], [23, 11], [28, 30], [29, 0], [29, 5], [29, 4], [1, 16], [3, 5], [3, 16], [2, 9], [2, 8], [4, 17], [7, 10], [7, 6], [7, 16], [6, 8], [6, 12], [9, 11], [9, 10], [8, 14], [13, 15], [13, 18], [12, 19], [17, 18]], "features": {"0": "4", "1": "1", "2": "2", "3": "2", "4": "2", "5": "2", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3"}} -------------------------------------------------------------------------------- /dataset/18.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 8], [11, 15], [10, 7], [13, 0], [13, 3], [13, 2], [12, 8], [12, 16], [15, 14], [14, 4], [14, 16], [17, 4], [18, 4], [1, 9], [3, 9], [2, 6], [5, 8], [5, 7], [5, 6], [6, 9]], "features": {"0": "4", "1": "1", "2": "2", "3": "2", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3"}} -------------------------------------------------------------------------------- /dataset/19.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 0], [11, 3], [11, 4], [10, 7], [13, 8], [13, 15], [12, 8], [12, 14], [15, 16], [14, 16], [17, 2], [16, 2], [1, 9], [3, 6], [5, 8], [5, 7], [5, 6], [4, 9], [6, 9]], "features": {"0": "4", "1": "1", "2": "1", "3": "2", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3"}} -------------------------------------------------------------------------------- /dataset/2.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 26], [24, 22], [25, 26], [25, 23], [26, 16], [27, 28], [27, 6], [20, 14], [20, 22], [20, 23], [21, 13], [21, 7], [21, 6], [22, 15], [1, 18], [0, 18], [3, 19], [2, 18], [5, 19], [4, 19], [9, 15], [8, 15], [11, 16], [10, 16], [13, 17], [12, 14], [12, 17], [17, 19], [17, 18]], "features": {"0": "7", "1": "7", "2": "7", "3": "7", "4": "7", "5": "7", "6": "1", "7": "1", "8": "1", "9": "1", "10": "1", "11": "1", "12": "2", "13": "2", "14": "2", "15": "2", "16": "2", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3"}} -------------------------------------------------------------------------------- /dataset/20.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 8], [11, 10], [10, 2], [10, 12], [13, 0], [13, 4], [13, 6], [12, 9], [15, 2], [14, 1], [14, 3], [14, 4], [3, 6], [5, 9], [5, 8], [5, 7], [7, 6]], "features": {"0": "5", "1": "4", "2": "1", "3": "2", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3"}} -------------------------------------------------------------------------------- /dataset/21.json: -------------------------------------------------------------------------------- 1 | {"edges": [[20, 0], [20, 21], [20, 18], [21, 19], [1, 13], [1, 14], [3, 12], [3, 6], [2, 15], [5, 12], [5, 17], [4, 11], [4, 15], [4, 14], [7, 9], [7, 6], [6, 8], [9, 10], [8, 10], [11, 13], [11, 12], [15, 16], [17, 19], [17, 16], [16, 18]], "features": {"0": "5", "1": "4", "2": "4", "3": "2", "4": "2", "5": "2", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3"}} -------------------------------------------------------------------------------- /dataset/22.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 27], [24, 21], [25, 9], [25, 2], [25, 7], [26, 28], [26, 23], [27, 28], [20, 21], [20, 7], [21, 23], [22, 8], [22, 3], [22, 18], [1, 19], [1, 17], [0, 16], [5, 17], [5, 16], [4, 10], [4, 16], [6, 18], [6, 17], [9, 8], [11, 10], [11, 13], [10, 12], [13, 15], [12, 14], [15, 14], [19, 18]], "features": {"0": "4", "1": "4", "2": "4", "3": "1", "4": "2", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3"}} -------------------------------------------------------------------------------- /dataset/23.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 9], [24, 19], [25, 27], [25, 22], [26, 27], [26, 23], [27, 5], [20, 18], [20, 22], [20, 23], [21, 8], [21, 17], [28, 5], [1, 11], [1, 14], [0, 16], [3, 12], [2, 10], [4, 13], [7, 15], [6, 11], [6, 15], [6, 16], [11, 10], [10, 12], [13, 12], [13, 14], [15, 17], [17, 18], [16, 19], [19, 18]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "1", "5": "1", "6": "2", "7": "2", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3"}} -------------------------------------------------------------------------------- /dataset/24.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 5], [11, 15], [10, 5], [10, 14], [13, 15], [13, 14], [13, 17], [12, 0], [12, 2], [12, 8], [16, 9], [16, 18], [19, 1], [19, 18], [1, 9], [3, 20], [2, 4], [5, 4], [4, 7], [7, 6], [6, 9], [6, 8], [20, 8]], "features": {"0": "4", "1": "1", "2": "2", "3": "2", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3"}} -------------------------------------------------------------------------------- /dataset/25.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 27], [24, 14], [25, 19], [25, 20], [26, 21], [26, 23], [27, 22], [20, 12], [21, 9], [22, 10], [23, 13], [28, 13], [29, 14], [1, 33], [0, 32], [3, 9], [3, 32], [2, 11], [2, 12], [5, 17], [5, 7], [4, 33], [4, 10], [7, 32], [6, 8], [6, 18], [9, 15], [8, 33], [11, 19], [11, 17], [10, 16], [13, 15], [12, 18], [14, 16], [17, 30], [18, 31]], "features": {"0": "4", "1": "4", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "2", "8": "2", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3", "31": "3", "32": "3", "33": "3"}} -------------------------------------------------------------------------------- /dataset/26.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 15], [11, 6], [10, 14], [10, 6], [13, 9], [13, 17], [12, 7], [12, 16], [15, 18], [14, 18], [17, 16], [18, 0], [1, 4], [1, 7], [3, 9], [3, 8], [2, 8], [5, 8], [5, 4], [4, 6], [7, 9]], "features": {"0": "5", "1": "4", "2": "4", "3": "2", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3"}} -------------------------------------------------------------------------------- /dataset/27.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 1], [11, 8], [11, 16], [10, 9], [10, 12], [13, 2], [13, 4], [13, 6], [12, 1], [15, 8], [14, 3], [14, 5], [14, 6], [17, 2], [18, 3], [0, 9], [0, 6], [7, 8], [7, 6]], "features": {"0": "4", "1": "4", "2": "1", "3": "1", "4": "1", "5": "1", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3"}} -------------------------------------------------------------------------------- /dataset/28.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 10], [11, 2], [10, 9], [10, 3], [13, 12], [13, 15], [12, 2], [12, 14], [15, 17], [14, 16], [17, 0], [17, 16], [1, 9], [3, 7], [3, 8], [5, 4], [5, 7], [4, 9], [4, 6], [6, 8]], "features": {"0": "7", "1": "1", "2": "1", "3": "2", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3"}} -------------------------------------------------------------------------------- /dataset/29.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 0], [11, 5], [11, 6], [10, 13], [10, 15], [13, 4], [13, 6], [12, 9], [12, 3], [12, 5], [15, 2], [15, 8], [14, 1], [14, 9], [14, 7], [5, 7], [6, 8]], "features": {"0": "4", "1": "4", "2": "4", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "2", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3"}} -------------------------------------------------------------------------------- /dataset/3.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 1], [25, 27], [25, 22], [26, 27], [26, 23], [27, 0], [20, 19], [20, 15], [21, 6], [21, 22], [21, 23], [1, 15], [3, 7], [2, 7], [5, 8], [5, 6], [4, 11], [4, 12], [7, 17], [9, 11], [9, 8], [9, 14], [8, 10], [11, 15], [10, 13], [10, 12], [13, 18], [12, 16], [14, 19], [17, 18], [17, 16]], "features": {"0": "5", "1": "1", "2": "1", "3": "1", "4": "2", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3"}} -------------------------------------------------------------------------------- /dataset/30.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 26], [24, 22], [25, 26], [25, 23], [26, 27], [20, 1], [20, 3], [20, 2], [21, 1], [21, 22], [21, 23], [0, 19], [3, 19], [3, 6], [5, 9], [5, 19], [4, 9], [4, 13], [7, 10], [7, 6], [6, 9], [6, 8], [8, 11], [11, 12], [10, 12], [13, 15], [13, 14], [15, 17], [14, 16], [17, 18], [16, 18]], "features": {"0": "4", "1": "4", "2": "1", "3": "2", "4": "2", "5": "2", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3"}} -------------------------------------------------------------------------------- /dataset/31.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 3], [11, 6], [10, 13], [10, 5], [13, 12], [12, 9], [15, 0], [15, 3], [15, 14], [14, 17], [14, 16], [17, 19], [16, 18], [19, 20], [18, 20], [1, 7], [2, 8], [5, 4], [5, 8], [4, 9], [4, 7], [7, 6], [6, 8]], "features": {"0": "4", "1": "1", "2": "1", "3": "2", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3"}} -------------------------------------------------------------------------------- /dataset/32.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 6], [10, 8], [10, 4], [10, 14], [13, 8], [13, 15], [12, 1], [12, 3], [12, 5], [15, 16], [14, 16], [17, 18], [17, 5], [16, 0], [19, 18], [3, 8], [3, 7], [2, 9], [4, 9], [7, 6], [6, 9]], "features": {"0": "5", "1": "4", "2": "1", "3": "2", "4": "2", "5": "2", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3"}} -------------------------------------------------------------------------------- /dataset/33.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 19], [24, 29], [25, 20], [25, 29], [26, 27], [26, 28], [26, 30], [27, 21], [20, 13], [21, 17], [22, 28], [22, 17], [23, 15], [1, 18], [1, 12], [0, 11], [0, 10], [3, 14], [2, 18], [5, 9], [5, 10], [5, 13], [4, 16], [7, 18], [7, 14], [7, 17], [6, 9], [6, 15], [9, 11], [8, 15], [8, 16], [11, 16], [10, 12], [13, 19], [12, 14]], "features": {"0": "4", "1": "4", "2": "4", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "2", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3"}} -------------------------------------------------------------------------------- /dataset/34.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 21], [25, 3], [26, 4], [20, 1], [20, 23], [21, 2], [22, 8], [22, 5], [1, 9], [0, 10], [3, 17], [2, 12], [4, 18], [7, 8], [7, 15], [7, 16], [6, 11], [6, 10], [6, 13], [9, 11], [9, 12], [8, 10], [13, 14], [12, 14], [15, 17], [17, 18], [16, 19], [19, 18]], "features": {"0": "5", "1": "1", "2": "1", "3": "1", "4": "1", "5": "1", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3"}} -------------------------------------------------------------------------------- /dataset/35.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 25], [24, 21], [25, 1], [25, 23], [20, 19], [20, 23], [21, 19], [22, 3], [22, 7], [22, 17], [23, 0], [2, 13], [2, 17], [5, 12], [5, 4], [4, 8], [6, 14], [6, 17], [9, 8], [8, 10], [8, 11], [13, 12], [13, 14], [12, 15], [15, 16], [14, 18], [16, 19]], "features": {"0": "5", "1": "5", "2": "4", "3": "4", "4": "2", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3"}} -------------------------------------------------------------------------------- /dataset/36.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 8], [11, 3], [11, 13], [10, 2], [10, 5], [10, 6], [13, 14], [12, 0], [12, 5], [12, 4], [15, 14], [15, 17], [15, 16], [17, 19], [16, 18], [19, 20], [18, 20], [1, 9], [4, 9], [7, 8], [7, 6], [6, 9]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "2", "5": "2", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3"}} -------------------------------------------------------------------------------- /dataset/37.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 25], [24, 27], [24, 23], [25, 22], [26, 21], [20, 3], [20, 21], [20, 22], [21, 23], [28, 0], [28, 5], [28, 6], [1, 18], [3, 18], [2, 9], [2, 8], [2, 7], [5, 4], [4, 17], [7, 10], [9, 12], [8, 11], [11, 15], [11, 16], [10, 13], [10, 14], [12, 18], [12, 17], [17, 19]], "features": {"0": "4", "1": "1", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3"}} -------------------------------------------------------------------------------- /dataset/38.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 14], [25, 32], [25, 31], [25, 6], [26, 30], [26, 21], [26, 29], [27, 39], [27, 17], [20, 19], [20, 12], [21, 7], [21, 6], [22, 2], [22, 15], [22, 6], [23, 13], [28, 18], [28, 40], [29, 33], [40, 10], [1, 30], [0, 38], [3, 8], [5, 18], [5, 12], [5, 17], [4, 8], [7, 15], [9, 39], [8, 33], [13, 11], [13, 15], [12, 16], [11, 19], [11, 14], [38, 36], [38, 35], [14, 16], [31, 35], [30, 34], [37, 33], [37, 34], [36, 32]], "features": {"0": "14", "1": "5", "2": "1", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "2", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3", "31": "3", "32": "3", "33": "3", "34": "3", "35": "3", "36": "3", "37": "3", "38": "3", "39": "3", "40": "3"}} -------------------------------------------------------------------------------- /dataset/39.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 0], [24, 23], [24, 25], [25, 27], [25, 6], [26, 0], [26, 28], [26, 6], [20, 2], [20, 5], [20, 21], [21, 3], [21, 22], [22, 23], [23, 4], [28, 1], [28, 7], [5, 12], [9, 11], [9, 12], [9, 14], [8, 10], [8, 13], [8, 12], [11, 18], [11, 17], [10, 15], [10, 16], [13, 19], [14, 19]], "features": {"0": "4", "1": "4", "2": "1", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3"}} -------------------------------------------------------------------------------- /dataset/4.json: -------------------------------------------------------------------------------- 1 | {"edges": [[20, 4], [20, 22], [21, 18], [1, 18], [1, 17], [0, 13], [3, 14], [2, 11], [5, 16], [4, 19], [7, 19], [6, 17], [9, 13], [9, 14], [8, 11], [8, 13], [8, 12], [11, 10], [10, 14], [12, 15], [15, 17], [15, 16], [16, 19]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "1", "5": "1", "6": "1", "7": "1", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3"}} -------------------------------------------------------------------------------- /dataset/40.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 0], [24, 5], [24, 6], [20, 18], [20, 23], [21, 17], [22, 18], [23, 19], [1, 12], [3, 12], [3, 15], [2, 9], [2, 8], [2, 10], [5, 4], [4, 11], [7, 11], [7, 8], [7, 12], [9, 13], [11, 16], [10, 14], [15, 18], [15, 17], [17, 19]], "features": {"0": "4", "1": "1", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3"}} -------------------------------------------------------------------------------- /dataset/41.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 26], [24, 23], [25, 27], [25, 23], [26, 30], [27, 30], [20, 17], [20, 16], [21, 19], [21, 18], [22, 0], [22, 2], [22, 5], [23, 5], [28, 33], [28, 31], [28, 34], [29, 32], [29, 6], [1, 11], [1, 7], [3, 8], [3, 4], [2, 11], [2, 6], [4, 11], [7, 8], [7, 9], [9, 13], [9, 12], [8, 10], [10, 15], [10, 14], [13, 17], [12, 16], [15, 19], [14, 18], [31, 32], [37, 36], [37, 35], [36, 34], [35, 33]], "features": {"0": "4", "1": "2", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3", "31": "3", "32": "3", "33": "3", "34": "3", "35": "3", "36": "3", "37": "3"}} -------------------------------------------------------------------------------- /dataset/42.json: -------------------------------------------------------------------------------- 1 | {"edges": [[20, 18], [20, 22], [21, 19], [21, 22], [22, 0], [1, 15], [3, 5], [3, 15], [2, 16], [5, 7], [5, 6], [4, 15], [4, 16], [7, 9], [7, 11], [6, 8], [6, 10], [9, 14], [8, 13], [11, 12], [10, 12], [17, 19], [17, 18], [17, 16]], "features": {"0": "14", "1": "4", "2": "1", "3": "2", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3"}} -------------------------------------------------------------------------------- /dataset/43.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 9], [11, 5], [11, 6], [10, 9], [10, 12], [13, 15], [13, 14], [13, 6], [12, 4], [12, 7], [15, 16], [14, 0], [14, 17], [17, 18], [16, 1], [16, 18], [19, 8], [19, 3], [19, 4], [18, 2], [7, 8]], "features": {"0": "5", "1": "5", "2": "5", "3": "4", "4": "1", "5": "1", "6": "2", "7": "2", "8": "2", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3"}} -------------------------------------------------------------------------------- /dataset/44.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 5], [11, 14], [11, 7], [10, 1], [10, 5], [13, 1], [13, 16], [12, 2], [12, 5], [12, 6], [15, 6], [15, 4], [15, 14], [14, 0], [16, 3], [7, 8], [9, 8]], "features": {"0": "14", "1": "1", "2": "1", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3"}} -------------------------------------------------------------------------------- /dataset/45.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 8], [10, 1], [10, 7], [13, 1], [13, 0], [13, 2], [12, 8], [14, 2], [3, 9], [3, 4], [3, 7], [5, 4], [5, 6], [6, 8]], "features": {"0": "4", "1": "1", "2": "2", "3": "3", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3"}} -------------------------------------------------------------------------------- /dataset/46.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 22], [25, 23], [26, 8], [26, 28], [26, 22], [27, 9], [27, 29], [27, 23], [20, 0], [20, 2], [20, 4], [21, 1], [21, 3], [21, 5], [22, 6], [23, 7], [28, 30], [29, 31], [3, 19], [3, 18], [2, 17], [2, 16], [5, 7], [4, 6], [9, 33], [8, 32], [11, 10], [11, 15], [11, 14], [10, 13], [10, 12], [13, 17], [12, 16], [15, 19], [14, 18], [31, 35], [30, 34], [35, 33], [34, 32]], "features": {"0": "4", "1": "4", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3", "31": "3", "32": "3", "33": "3", "34": "3", "35": "3"}} -------------------------------------------------------------------------------- /dataset/47.json: -------------------------------------------------------------------------------- 1 | {"edges": [[20, 10], [20, 6], [21, 1], [21, 0], [21, 2], [1, 11], [3, 5], [3, 7], [2, 12], [5, 19], [4, 8], [4, 6], [7, 9], [7, 13], [9, 19], [9, 15], [8, 10], [8, 14], [11, 13], [11, 17], [10, 16], [12, 18], [12, 14], [15, 17], [16, 18]], "features": {"0": "4", "1": "2", "2": "2", "3": "2", "4": "2", "5": "2", "6": "2", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3"}} -------------------------------------------------------------------------------- /dataset/48.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 7], [20, 0], [20, 3], [20, 5], [21, 6], [22, 6], [23, 7], [1, 11], [0, 13], [2, 16], [5, 17], [5, 16], [4, 9], [4, 11], [4, 12], [7, 17], [6, 12], [9, 10], [9, 14], [8, 11], [8, 10], [8, 13], [10, 15], [13, 16], [15, 19], [14, 18], [19, 18]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "2", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3"}} -------------------------------------------------------------------------------- /dataset/49.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 19], [24, 25], [25, 4], [25, 22], [26, 27], [26, 21], [27, 5], [27, 23], [20, 16], [20, 23], [21, 16], [22, 2], [22, 18], [23, 3], [28, 9], [28, 17], [29, 2], [1, 13], [1, 17], [0, 33], [3, 30], [5, 32], [4, 31], [7, 8], [6, 8], [9, 10], [8, 15], [11, 33], [10, 33], [13, 12], [13, 16], [12, 15], [12, 14], [15, 17], [14, 19], [14, 18]], "features": {"0": "4", "1": "1", "2": "1", "3": "1", "4": "1", "5": "1", "6": "1", "7": "1", "8": "2", "9": "2", "10": "2", "11": "2", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "30": "3", "31": "3", "32": "3", "33": "3"}} -------------------------------------------------------------------------------- /dataset/5.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 16], [25, 10], [25, 2], [25, 6], [20, 16], [20, 23], [21, 19], [21, 22], [22, 9], [22, 23], [1, 7], [0, 7], [3, 9], [5, 12], [5, 6], [4, 9], [7, 15], [8, 19], [8, 10], [11, 18], [11, 12], [11, 14], [13, 12], [13, 15], [15, 17], [14, 17], [16, 19]], "features": {"0": "1", "1": "1", "2": "1", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "2", "9": "2", "10": "2", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3"}} -------------------------------------------------------------------------------- /dataset/50.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 1], [11, 10], [11, 3], [10, 15], [10, 4], [13, 9], [13, 14], [12, 8], [12, 14], [15, 2], [17, 16], [16, 2], [1, 7], [0, 5], [5, 7], [5, 6], [4, 7], [6, 9], [6, 8]], "features": {"0": "5", "1": "1", "2": "1", "3": "1", "4": "2", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3"}} -------------------------------------------------------------------------------- /dataset/6.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 1], [10, 2], [10, 0], [10, 12], [12, 3], [1, 5], [2, 4], [5, 8], [5, 9], [4, 7], [4, 6], [7, 9], [6, 8]], "features": {"0": "4", "1": "1", "2": "2", "3": "2", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3"}} -------------------------------------------------------------------------------- /dataset/7.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 15], [11, 6], [10, 5], [10, 14], [13, 9], [13, 12], [12, 8], [12, 2], [15, 14], [1, 3], [1, 5], [0, 7], [3, 8], [3, 4], [5, 6], [4, 9], [4, 7], [7, 6]], "features": {"0": "4", "1": "2", "2": "2", "3": "3", "4": "3", "5": "3", "6": "3", "7": "3", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3"}} -------------------------------------------------------------------------------- /dataset/8.json: -------------------------------------------------------------------------------- 1 | {"edges": [[24, 1], [25, 2], [20, 18], [20, 17], [21, 14], [21, 23], [22, 15], [22, 23], [1, 0], [0, 10], [0, 3], [0, 2], [5, 9], [4, 9], [7, 11], [7, 10], [6, 8], [6, 10], [9, 18], [8, 13], [11, 12], [13, 17], [13, 16], [12, 15], [12, 14], [16, 19], [19, 18]], "features": {"0": "6", "1": "1", "2": "1", "3": "1", "4": "1", "5": "1", "6": "2", "7": "2", "8": "2", "9": "2", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3"}} -------------------------------------------------------------------------------- /dataset/9.json: -------------------------------------------------------------------------------- 1 | {"edges": [[11, 0], [11, 8], [10, 1], [10, 8], [10, 6], [13, 6], [13, 12], [13, 16], [12, 5], [12, 15], [15, 18], [14, 9], [14, 19], [14, 2], [17, 18], [17, 7], [17, 16], [3, 7], [5, 8], [4, 7], [9, 8]], "features": {"0": "14", "1": "1", "2": "1", "3": "1", "4": "1", "5": "2", "6": "2", "7": "2", "8": "3", "9": "3", "10": "3", "11": "3", "12": "3", "13": "3", "14": "3", "15": "3", "16": "3", "17": "3", "18": "3", "19": "3"}} -------------------------------------------------------------------------------- /features/nci1.csv: -------------------------------------------------------------------------------- 1 | name,x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8,x_9,x_10,x_11,x_12,x_13,x_14,x_15,x_16,x_17,x_18,x_19,x_20,x_21,x_22,x_23,x_24,x_25,x_26,x_27,x_28,x_29,x_30,x_31,x_32,x_33,x_34,x_35,x_36,x_37,x_38,x_39,x_40,x_41,x_42,x_43,x_44,x_45,x_46,x_47 2 | 0,-2.0,0.0,0.0,0.0,0.0,-1.0,2.0,0.0,0.0,-1.0,-2.0,0.0,1.0,1.0,0.0,-1.0,4.0,-1.0,5.0,0.0,-3.0,0.0,0.0,0.0,-1.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,-1.0,0.0,2.0,0.0,1.0,-1.0,0.0,0.0,-1.0,0.0,1.0,-1.0,0.0,-1.0,4.0,0.0 3 | 1,-2.0,0.0,0.0,0.0,0.0,-1.0,2.0,0.0,0.0,-1.0,-2.0,0.0,1.0,0.0,0.0,-1.0,0.0,-3.0,0.0,0.0,-11.0,0.0,-1.0,0.0,-2.0,0.0,1.0,0.0,-1.0,1.0,0.0,0.0,2.0,0.0,1.0,0.0,1.0,0.0,-2.0,0.0,1.0,6.0,0.0,0.0,0.0,0.0,4.0,1.0 4 | 10,-3.0,0.0,0.0,0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 53 | -------------------------------------------------------------------------------- /graph_embedding.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benedekrozemberczki/NestedSubtreeHash/58f21581f512f2700de543202656a021c9354143/graph_embedding.jpeg -------------------------------------------------------------------------------- /src/hashing_machine.py: -------------------------------------------------------------------------------- 1 | """Hashing machine to create gtraph signatures.""" 2 | 3 | import glob 4 | import json 5 | import hashlib 6 | import pandas as pd 7 | import networkx as nx 8 | from tqdm import tqdm 9 | from joblib import Parallel, delayed 10 | 11 | class SubtreeHashingMachine: 12 | """ 13 | Weisfeiler Lehman feature extractor class. 14 | """ 15 | def __init__(self, graph, features, args): 16 | """ 17 | Initialization method which executes feature extraction. 18 | :param graph: The Nx graph object. 19 | :param features: Feature hash table. 20 | :param iterations: Number of WL iterations. 21 | """ 22 | self.graph = graph 23 | self.features = features 24 | self.args = args 25 | self.create_base_features() 26 | self.do_recursions() 27 | 28 | def single_hash(self, feature): 29 | """ 30 | Hashing a feature and creating a numeric digest in 16 bits. 31 | :param feature: Node feature. 32 | :return hash_value: Hash of the features. 33 | :return number: Numeric value of the hash. 34 | """ 35 | hash_object = hashlib.md5(feature.encode()) 36 | hash_value = hash_object.hexdigest() 37 | number = int(hash_value, 16) 38 | return number, hash_value 39 | 40 | def hashing_tool(self, scores, feature): 41 | """ 42 | Given a graph representation and a structural feature. 43 | update the representation with the hash of the feature. 44 | :param scores: Repesentation. 45 | :param feature: Structural feature string. 46 | :return scores: Updated representation. 47 | :return index_hash_value: 48 | """ 49 | feature = str(feature) 50 | index_number, index_hash_value = self.single_hash(feature) 51 | sign_number, sign_hash_value = self.single_hash(feature + "_") 52 | index = index_number % self.args.dimensions 53 | sign = (sign_number % 2)*2 -1.0 54 | scores[index] = scores[index] + sign 55 | return scores, index_hash_value 56 | 57 | def create_base_features(self): 58 | """ 59 | Hashing the raw node features of the graph to a vector. 60 | """ 61 | scores = [0.0]*self.args.dimensions 62 | for feature in self.features: 63 | scores, hash_value = self.hashing_tool(scores, feature) 64 | self.scores = scores 65 | 66 | def do_a_recursion(self): 67 | """ 68 | The method does a single WL recursion. 69 | Creates a hash vector with the features. 70 | :return new_features: The hash table with extracted WL features. 71 | """ 72 | new_features = {} 73 | scores = [0.0]*self.args.dimensions 74 | for node in self.graph.nodes(): 75 | nebs = self.graph.neighbors(node) 76 | degs = [self.features[neb] for neb in nebs] 77 | to_join = [str(self.features[node])]+sorted([str(deg) for deg in degs]) 78 | feature = "_".join(to_join) 79 | scores, hash_value = self.hashing_tool(scores, feature) 80 | new_features[node] = hash_value 81 | self.scores = self.scores + scores 82 | return new_features 83 | 84 | def do_recursions(self): 85 | """ 86 | The method does a series of WL recursions. 87 | """ 88 | for _ in range(self.args.wl_iterations): 89 | self.features = self.do_a_recursion() 90 | 91 | def dataset_reader(path): 92 | """ 93 | Function to read the graph and features from a json file. 94 | :param path: The path to the graph json. 95 | :return graph: The graph object. 96 | :return features: Features hash table. 97 | :return name: Name of the graph. 98 | """ 99 | name = path.strip(".json").split("/")[-1] 100 | data = json.load(open(path)) 101 | graph = nx.from_edgelist(data["edges"]) 102 | 103 | if "features" in data.keys(): 104 | features = data["features"] 105 | else: 106 | features = nx.degree(graph) 107 | features = {int(k):v for k, v, in features.items()} 108 | return graph, features, name 109 | 110 | def hash_wrap(path, args): 111 | """ 112 | Function to extract WL features from a graph. 113 | :param path: The path to the graph json. 114 | :param args: Arguments object. 115 | return representation: Graph representation. 116 | """ 117 | graph, features, name = dataset_reader(path) 118 | machine = SubtreeHashingMachine(graph, features, args) 119 | representation = [name] + machine.scores 120 | return representation 121 | 122 | class DistributedHashingMachine: 123 | """ 124 | Class for parallel nested subtree hashing. 125 | """ 126 | def __init__(self, args): 127 | """ 128 | Setting up the model for hashing. 129 | :param args: Nested subtree hashing arguments. 130 | """ 131 | self.args = args 132 | self.graphs = glob.glob(args.input_path + "*.json") 133 | 134 | def execute_hashing(self): 135 | """ 136 | Function to create the representations in a parallel setup. 137 | """ 138 | self.hashes = Parallel(n_jobs=self.args.workers)(delayed(hash_wrap)(g, self.args) for g in tqdm(self.graphs)) 139 | 140 | def save_embedding(self): 141 | """ 142 | Function to save the embedding. 143 | """ 144 | self.feature_count = self.args.dimensions*(self.args.wl_iterations+1) 145 | self.column_names = ["name"] + [str(fet) for fet in range(self.feature_count)] 146 | self.hashes = pd.DataFrame(self.hashes, columns=self.column_names) 147 | self.hashes = self.hashes.sort_values(["name"]) 148 | self.hashes.to_csv(self.args.output_path, index=None) 149 | -------------------------------------------------------------------------------- /src/helpers.py: -------------------------------------------------------------------------------- 1 | """Parsing and printing tool.""" 2 | 3 | import argparse 4 | from texttable import Texttable 5 | 6 | def parameter_parser(): 7 | """ 8 | A method to parse up command line parameters. 9 | By default it gives an embedding of the partial NCI1 graph dataset. 10 | The default hyperparameters give a good quality representation without grid search. 11 | Representations are sorted by ID. 12 | """ 13 | parser = argparse.ArgumentParser(description="Run Nested Subtree Hashing.") 14 | 15 | parser.add_argument('--input-path', 16 | nargs='?', 17 | default='./dataset/', 18 | help='Input folder with jsons.') 19 | 20 | parser.add_argument('--output-path', 21 | nargs='?', 22 | default='./features/nci1.csv', 23 | help='Embeddings path.') 24 | 25 | parser.add_argument('--dimensions', 26 | type=int, 27 | default=16, 28 | help='Number of dimensions. Default is 16.') 29 | 30 | parser.add_argument('--workers', 31 | type=int, 32 | default=4, 33 | help='Number of workers. Default is 4.') 34 | 35 | parser.add_argument('--wl-iterations', 36 | type=int, 37 | default=2, 38 | help='Number of Weisfeiler-Lehman iterations. Default is 2.') 39 | 40 | return parser.parse_args() 41 | 42 | def tab_printer(args): 43 | """ 44 | Function to print the logs in a nice tabular format. 45 | :param args: Parameters used for the model. 46 | """ 47 | args = vars(args) 48 | keys = sorted(args.keys()) 49 | tab = Texttable() 50 | tab.add_rows([["Parameter", "Value"]]) 51 | tab.add_rows([[k.replace("_", " ").capitalize(), args[k]] for k in keys]) 52 | print(tab.draw()) 53 | -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | """Running the hashing machine.""" 2 | 3 | from helpers import parameter_parser, tab_printer 4 | from hashing_machine import DistributedHashingMachine 5 | 6 | def main(args): 7 | """ 8 | Main function to read the graph list, extract features, learn the embedding and save it. 9 | :param args: Object with the arguments. 10 | """ 11 | model = DistributedHashingMachine(args) 12 | model.execute_hashing() 13 | model.save_embedding() 14 | 15 | if __name__ == "__main__": 16 | args = parameter_parser() 17 | tab_printer(args) 18 | main(args) 19 | --------------------------------------------------------------------------------