Changeset 7804:b0806f58981d


Ignore:
Timestamp:
12/17/07 18:18:04 (5 years ago)
Author:
Robert Miller <rlmillster@…>
Branch:
default
Message:

compute the eigenspaces of the adj matrix of a graph, changed tabs to spaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/graphs/graph.py

    r7803 r7804  
    40994099            sage: P = graphs.PetersenGraph() 
    41004100            sage: P.spectrum() 
    4101             [-2.0, -2.0, -2.0, -2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0] 
     4101            [-2.0, -2.0, -2.0, -2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0] 
    41024102            sage: P.spectrum(laplacian=True)   # random low-order bits (at least for first eigenvalue) 
    4103             [-1.41325497305e-16, 2.0, 2.0, 2.0, 2.0, 2.0, 5.0, 5.0, 5.0, 5.0] 
     4103            [-1.41325497305e-16, 2.0, 2.0, 2.0, 2.0, 2.0, 5.0, 5.0, 5.0, 5.0] 
    41044104         
    41054105        """ 
     
    41134113        E = M.right_eigenvectors()[0] 
    41144114        v = [e.real() for e in E] 
    4115         v.sort() 
    4116         return v 
     4115        v.sort() 
     4116        return v 
     4117     
     4118    def eigenspaces(self, laplacian=False): 
     4119        """ 
     4120        Returns the eigenspaces of the adjacency matrix of the graph. 
     4121 
     4122        EXAMPLE: 
     4123            sage: C = graphs.CycleGraph(5) 
     4124            sage: E = C.eigenspaces() 
     4125            sage: E[0][0] 
     4126            -1.61803398875 
     4127            sage: E[1][0] 
     4128            Vector space of degree 5 and dimension 1 over Real Double Field 
     4129            User basis matrix: 
     4130            [ 0.632455532034 -0.632455532034   -0.4472135955 -0.013900198608 0.0738411279702] 
     4131 
     4132        """ 
     4133        if laplacian: 
     4134            M = self.kirchhoff_matrix() 
     4135        else: 
     4136            M = self.am() 
     4137        from sage.matrix.constructor import matrix 
     4138        from sage.rings.real_double import RDF 
     4139        M = matrix(RDF, M.rows()) 
     4140        return M.eigenspaces() 
    41174141     
    41184142    ### Representations 
     
    47784802            NXG.delete_edges_from(edges_to_delete) 
    47794803         
    4780         if inplace: 
     4804        if inplace: 
    47814805            self._nxg = NXG 
    47824806        else: 
Note: See TracChangeset for help on using the changeset viewer.