(self, filename, layer=None)
Saves the multi-order model in state file format 
        suitable to be used with InfoMap

        @param layer: if none, all layers will be export. If set to k, only 
            the k-th layer of the model will be exported.
Saves the multi-order model in state file format 
        suitable to be used with InfoMap
Saves the multi - order model in state file format suitable to be used with InfoMap
def saveStateFile(self, filename, layer=None):
        """
        Saves the multi-order model in state file format 
        suitable to be used with InfoMap

        @param layer: if none, all layers will be export. If set to k, only 
            the k-th layer of the model will be exported.
        """

        assert layer, 'Error: export of all layers currently not supported'

        name_map = self.layers[layer].getNodeNameMap()
        first_layer_map = self.layers[1].getNodeNameMap()
        T = self.layers[layer].getTransitionMatrix()

        file = open(filename,'w')

        file.write('# file generated by pathpy\n')
        file.write('*Vertices {0}\n'.format(self.layers[1].vcount()))

        for i in range(self.layers[1].vcount()):
            # each line contains uniqueID [name]
            file.write('{0} "{1}"\n'.format(first_layer_map[self.layers[1].nodes[i]]+1, self.layers[1].nodes[i]))

        # Write higher-order nodes to states section
        file.write('*States\n'.format(self.layers[1].vcount()))
        for i in range(self.layers[layer].vcount()):
            v = self.layers[layer].nodes[i]
            v_ix = name_map[v]
            v_path = self.layers[layer].HigherOrderNodeToPath(v)

            # each line contains uniqueID physicalID [name]
            file.write('{0} {1} "{2}"\n'.format(v_ix+1, first_layer_map[v_path[-1]]+1, v))
    
        file.write('*Links\n'.format(self.layers[1].vcount()))
        for e in self.layers[layer].edges:
            source = e[0]
            target = e[1]

            # Get source and target paths
            source_p = self.layers[layer].HigherOrderNodeToPath(source)            
            source_t = self.layers[layer].HigherOrderNodeToPath(target)

            source_ix = name_map[source]
            target_ix = name_map[target]
            
            # Get edge weight
            w_st = self.layers[layer].edges[e][1]

            # Get transition probability
            T_st = T[target_ix, source_ix]

            # Write entry to file
            # each line contains from to [weight]
            file.write('{0} {1} {2}\n'.format(source_ix+1, target_ix+1, T_st))

        file.close()
def saveStateFile ( self , filename , layer = None ) : assert layer , 'Error: export of all layers currently not supported' name_map = self . layers [ layer ] . getNodeNameMap ( ) first_layer_map = self . layers [ 1 ] . getNodeNameMap ( ) T = self . layers [ layer ] . getTransitionMatrix ( ) file = open ( filename , 'w' ) file . write ( '# file generated by pathpy\n' ) file . write ( '*Vertices {0}\n' . format ( self . layers [ 1 ] . vcount ( ) ) ) for i in range ( self . layers [ 1 ] . vcount ( ) ) : # each line contains uniqueID [name] file . write ( '{0} "{1}"\n' . format ( first_layer_map [ self . layers [ 1 ] . nodes [ i ] ] + 1 , self . layers [ 1 ] . nodes [ i ] ) ) # Write higher-order nodes to states section file . write ( '*States\n' . format ( self . layers [ 1 ] . vcount ( ) ) ) for i in range ( self . layers [ layer ] . vcount ( ) ) : v = self . layers [ layer ] . nodes [ i ] v_ix = name_map [ v ] v_path = self . layers [ layer ] . HigherOrderNodeToPath ( v ) # each line contains uniqueID physicalID [name] file . write ( '{0} {1} "{2}"\n' . format ( v_ix + 1 , first_layer_map [ v_path [ - 1 ] ] + 1 , v ) ) file . write ( '*Links\n' . format ( self . layers [ 1 ] . vcount ( ) ) ) for e in self . layers [ layer ] . edges : source = e [ 0 ] target = e [ 1 ] # Get source and target paths source_p = self . layers [ layer ] . HigherOrderNodeToPath ( source ) source_t = self . layers [ layer ] . HigherOrderNodeToPath ( target ) source_ix = name_map [ source ] target_ix = name_map [ target ] # Get edge weight w_st = self . layers [ layer ] . edges [ e ] [ 1 ] # Get transition probability T_st = T [ target_ix , source_ix ] # Write entry to file # each line contains from to [weight] file . write ( '{0} {1} {2}\n' . format ( source_ix + 1 , target_ix + 1 , T_st ) ) file . close ( )