@classmethod
def parse_dat(cls, fn, sep=' '):
    """ Parse Network data depending on type/extension """
    cls.log.debug('opening file: %s' % fn)
    inside = {'vertices': False, 'edges': False}
    for line in open(fn):
        line = line.strip()
        if line.startswith(('ROW LABELS:', '*vertices')) or inside['vertices']:
            if not inside['vertices']:
                inside['vertices'] = True
                continue
            if line.startswith('#') or not line.strip():
                inside['vertices'] = False
            elif line.startswith(('DATA', '*edges')):
                inside['vertices'] = False
                inside['edges'] = True
            else:
                continue
        elif line.startswith(('DATA', '*edges')) or inside['edges']:
            if not inside['edges']:
                inside['edges'] = True
                continue
            if line.startswith('#') or not line.strip() or len(line.split()
                ) < 2:
                inside['edges'] = False
            else:
                splitline = line.split(sep)
                row_size = len(splitline)
                if row_size == 2:
                    v1, v2 = splitline
                    w = 1
                    yield int(v1), int(v2), w, None
                elif row_size == 3:
                    v1, v2 = splitline[0:2]
                    w = int(splitline[2])
                    if w == 0:
                        continue
                    else:
                        yield int(v1), int(v2), w, None
                else:
                    raise NotImplementedError
