gklearn.utils.graphfiles

Utilities function to manage graph files

loadCT(filename)[source]

load data from a Chemical Table (.ct) file.

Notes

a typical example of data in .ct is like this:

3 2 <- number of nodes and edges

0.0000 0.0000 0.0000 C <- each line describes a node (x,y,z + label)

0.0000 0.0000 0.0000 C

0.0000 0.0000 0.0000 O

1 3 1 1 <- each line describes an edge : to, from, bond type, bond stereo

2 3 1 1

Check CTFile Formats file for detailed format discription.

loadDataset(filename, filename_y=None, extra_params=None)[source]

Read graph data from filename and load them as NetworkX graphs.

Parameters

filenamestring

The name of the file from where the dataset is read.

filename_ystring

The name of file of the targets corresponding to graphs.

extra_paramsdict

Extra parameters only designated to ‘.mat’ format.

Return

data : List of NetworkX graph.

y : List

Targets corresponding to graphs.

Notes

This function supports following graph dataset formats:

‘ds’: load data from .ds file. See comments of function loadFromDS for a example.

‘cxl’: load data from Graph eXchange Language file (.cxl file). See here for detail.

‘sdf’: load data from structured data file (.sdf file). See here for details.

‘mat’: Load graph data from a MATLAB (up to version 7.1) .mat file. See README in downloadable file for details.

‘txt’: Load graph data from a special .txt file. See here for details. Note here filename is the name of either .txt file in the dataset directory.

loadFromDS(filename, filename_y)[source]

Load data from .ds file.

Possible graph formats include:

‘.ct’: see function loadCT for detail.

‘.gxl’: see dunction loadGXL for detail.

Note these graph formats are checked automatically by the extensions of graph files.

loadFromXML(filename, extra_params)[source]
loadGXL(filename)[source]
loadMAT(filename, extra_params)[source]

Load graph data from a MATLAB (up to version 7.1) .mat file.

Notes

A MAT file contains a struct array containing graphs, and a column vector lx containing a class label for each graph. Check README in downloadable file for detailed structure.

loadSDF(filename)[source]

load data from structured data file (.sdf file).

Notes

A SDF file contains a group of molecules, represented in the similar way as in MOL format. Check here for detailed structure.

loadTXT(filename)[source]

Load graph data from a .txt file.

Notes

The graph data is loaded from separate files. Check README in downloadable file, 2018 for detailed structure.

saveDataset(Gn, y, gformat='gxl', group=None, filename='gfile', xparams=None)[source]

Save list of graphs.

saveGXL(graph, filename, method='default', node_labels=[], edge_labels=[], node_attrs=[], edge_attrs=[])[source]