Load node data from an input file located at *path*. Input file must be a plaintext .txt file with a JSON-style representation of a dict. The dict must have the top-level key ``Vdata`` or two top-level keys, ``initial_Vdata`` and ``twotbn_Vdata``. For example:: {
(self, path)
| 46 | |
| 47 | |
| 48 | def load(self, path): |
| 49 | ''' |
| 50 | Load node data from an input file located at *path*. Input file must be a plaintext .txt file with a JSON-style representation of a dict. The dict must have the top-level key ``Vdata`` or two top-level keys, ``initial_Vdata`` and ``twotbn_Vdata``. For example:: |
| 51 | |
| 52 | { |
| 53 | "Vdata": { |
| 54 | "<vertex 1>": <dict containing vertex 1 data>, |
| 55 | ... |
| 56 | "<vertex n>": <dict containing vertex n data> |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | or:: |
| 61 | |
| 62 | { |
| 63 | "initial_Vdata": { |
| 64 | "<vertex 1>": <dict containing vertex 1 data>, |
| 65 | ... |
| 66 | "<vertex n>": <dict containing vertex n data> |
| 67 | } |
| 68 | "twotbn_Vdata": { |
| 69 | "<vertex 1>": <dict containing vertex 1 data>, |
| 70 | ... |
| 71 | "<vertex n>": <dict containing vertex n data> |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | The function takes the following arguments: |
| 76 | 1. *path* -- The path to the text file that contains input data (e.g., "mydictionary.txt") |
| 77 | |
| 78 | In the static case, it modifies *Vdata* to hold the dictionary found at path. In the dynamic case, it modifies the *initial_Vdata* and *twotbn_Vdata* attributes to hold the dictionaries found at path. |
| 79 | |
| 80 | ''' |
| 81 | self.dictload(path) |
| 82 | |
| 83 | # try to load both for normal and dynamic cases |
| 84 | try: |
| 85 | self.Vdata = self.alldata["Vdata"] |
| 86 | except KeyError: |
| 87 | try: |
| 88 | self.initial_Vdata = self.alldata["initial_Vdata"] |
| 89 | self.twotbn_Vdata = self.alldata["twotbn_Vdata"] |
| 90 | except KeyError: |
| 91 | print "Error: NodeData did not recognize input file format." |
| 92 | |
| 93 | |
| 94 | # free unused memory |
| 95 | del self.alldata |
| 96 | |
| 97 | def entriestoinstances(self): |
| 98 | ''' |