Skip to content

Instantly share code, notes, and snippets.

@YabZhang
Created August 6, 2017 10:39
Show Gist options
  • Select an option

  • Save YabZhang/2a87488f580056a2139f4b892c60fb30 to your computer and use it in GitHub Desktop.

Select an option

Save YabZhang/2a87488f580056a2139f4b892c60fb30 to your computer and use it in GitHub Desktop.
sparse matrix transpose
#!/usr/bin/env python3
class SparseMatrix(object):
"""二维稀疏矩阵"""
def __init__(self, row, col):
self.m = row - 1
self.n = col - 1
self.seq = []
def set(self, x, y, val):
item = [x, y, val]
self.seq.append(item)
self.seq.sort()
def display(self):
pass
def transpose(self):
"""
1. i <=> j
2. m <=> n
3. self.seq.sort
"""
pass
if __name__ == '__main__':
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment