Skip to content

Instantly share code, notes, and snippets.

@enjalot
Last active October 28, 2015 21:05
Show Gist options
  • Save enjalot/1d9c7566cbe4e594314b to your computer and use it in GitHub Desktop.
Save enjalot/1d9c7566cbe4e594314b to your computer and use it in GitHub Desktop.
sparse matrix zoo II
{"info":"%-------------------------------------------------------------------------------\n%%MatrixMarket matrix coordinate integer general\n%-------------------------------------------------------------------------------\n% UF Sparse Matrix Collection, Tim Davis\n% http://www.cise.ufl.edu/research/sparse/matrices/JGD_SPG/08blocks\n% name: JGD_SPG/08blocks\n% [Symmetric powers of graphs from Gordon Royle, Univ Western Australia]\n% id: 2194\n% date: 2008\n% author: G. Royle\n% ed: J.-G. Dumas\n% fields: name title A id date author ed kind notes\n% kind: combinatorial problem\n%-------------------------------------------------------------------------------\n% notes:\n% Symmetric powers of graphs from Gordon Royle, Univ Western Australia\n% From Jean-Guillaume Dumas' Sparse Integer Matrix Collection, \n% http://ljk.imag.fr/membres/Jean-Guillaume.Dumas/simc.html \n% \n% http://www.csse.uwa.edu.au/~gordon/sympower.html \n% \n% Filename in JGD collection: SPG/08blocks.sms \n","meta":{"rows":"300","cols":"300","value":"300","rowIndex":"i","colIndex":"j"},"data":[{"i":37,"j":1,"value":1},{"i":1,"j":2,"value":2},{"i":37,"j":2,"value":2},{"i":2,"j":3,"value":3},{"i":37,"j":3,"value":3},{"i":3,"j":4,"value":4},{"i":37,"j":4,"value":4},{"i":4,"j":5,"value":5},{"i":37,"j":5,"value":5},{"i":5,"j":6,"value":6},{"i":37,"j":6,"value":6},{"i":6,"j":7,"value":7},{"i":37,"j":7,"value":7},{"i":7,"j":8,"value":8},{"i":37,"j":8,"value":8},{"i":8,"j":9,"value":9},{"i":37,"j":9,"value":9},{"i":9,"j":10,"value":10},{"i":37,"j":10,"value":10},{"i":10,"j":11,"value":11},{"i":37,"j":11,"value":11},{"i":11,"j":12,"value":12},{"i":37,"j":12,"value":12},{"i":12,"j":13,"value":13},{"i":37,"j":13,"value":13},{"i":13,"j":14,"value":14},{"i":37,"j":14,"value":14},{"i":14,"j":15,"value":15},{"i":37,"j":15,"value":15},{"i":15,"j":16,"value":16},{"i":37,"j":16,"value":16},{"i":16,"j":17,"value":17},{"i":37,"j":17,"value":17},{"i":17,"j":18,"value":18},{"i":37,"j":18,"value":18},{"i":18,"j":19,"value":19},{"i":37,"j":19,"value":19},{"i":19,"j":20,"value":20},{"i":37,"j":20,"value":20},{"i":20,"j":21,"value":21},{"i":37,"j":21,"value":21},{"i":21,"j":22,"value":22},{"i":37,"j":22,"value":22},{"i":22,"j":23,"value":23},{"i":37,"j":23,"value":23},{"i":23,"j":24,"value":24},{"i":37,"j":24,"value":24},{"i":24,"j":25,"value":25},{"i":37,"j":25,"value":25},{"i":25,"j":26,"value":26},{"i":37,"j":26,"value":26},{"i":26,"j":27,"value":27},{"i":37,"j":27,"value":27},{"i":27,"j":28,"value":28},{"i":37,"j":28,"value":28},{"i":28,"j":29,"value":29},{"i":37,"j":29,"value":29},{"i":29,"j":30,"value":30},{"i":37,"j":30,"value":30},{"i":30,"j":31,"value":31},{"i":37,"j":31,"value":31},{"i":31,"j":32,"value":32},{"i":37,"j":32,"value":32},{"i":32,"j":33,"value":33},{"i":37,"j":33,"value":33},{"i":33,"j":34,"value":34},{"i":37,"j":34,"value":34},{"i":34,"j":35,"value":35},{"i":37,"j":35,"value":35},{"i":35,"j":36,"value":36},{"i":37,"j":36,"value":36},{"i":36,"j":37,"value":37},{"i":37,"j":37,"value":37},{"i":74,"j":38,"value":38},{"i":38,"j":39,"value":39},{"i":74,"j":39,"value":39},{"i":39,"j":40,"value":40},{"i":74,"j":40,"value":40},{"i":40,"j":41,"value":41},{"i":74,"j":41,"value":41},{"i":41,"j":42,"value":42},{"i":74,"j":42,"value":42},{"i":42,"j":43,"value":43},{"i":74,"j":43,"value":43},{"i":43,"j":44,"value":44},{"i":74,"j":44,"value":44},{"i":44,"j":45,"value":45},{"i":74,"j":45,"value":45},{"i":45,"j":46,"value":46},{"i":74,"j":46,"value":46},{"i":46,"j":47,"value":47},{"i":74,"j":47,"value":47},{"i":47,"j":48,"value":48},{"i":74,"j":48,"value":48},{"i":48,"j":49,"value":49},{"i":74,"j":49,"value":49},{"i":49,"j":50,"value":50},{"i":74,"j":50,"value":50},{"i":50,"j":51,"value":51},{"i":74,"j":51,"value":51},{"i":51,"j":52,"value":52},{"i":74,"j":52,"value":52},{"i":52,"j":53,"value":53},{"i":74,"j":53,"value":53},{"i":53,"j":54,"value":54},{"i":74,"j":54,"value":54},{"i":54,"j":55,"value":55},{"i":74,"j":55,"value":55},{"i":55,"j":56,"value":56},{"i":74,"j":56,"value":56},{"i":56,"j":57,"value":57},{"i":74,"j":57,"value":57},{"i":57,"j":58,"value":58},{"i":74,"j":58,"value":58},{"i":58,"j":59,"value":59},{"i":74,"j":59,"value":59},{"i":59,"j":60,"value":60},{"i":74,"j":60,"value":60},{"i":60,"j":61,"value":61},{"i":74,"j":61,"value":61},{"i":61,"j":62,"value":62},{"i":74,"j":62,"value":62},{"i":62,"j":63,"value":63},{"i":74,"j":63,"value":63},{"i":63,"j":64,"value":64},{"i":74,"j":64,"value":64},{"i":64,"j":65,"value":65},{"i":74,"j":65,"value":65},{"i":65,"j":66,"value":66},{"i":74,"j":66,"value":66},{"i":66,"j":67,"value":67},{"i":74,"j":67,"value":67},{"i":67,"j":68,"value":68},{"i":74,"j":68,"value":68},{"i":68,"j":69,"value":69},{"i":74,"j":69,"value":69},{"i":69,"j":70,"value":70},{"i":74,"j":70,"value":70},{"i":70,"j":71,"value":71},{"i":74,"j":71,"value":71},{"i":71,"j":72,"value":72},{"i":74,"j":72,"value":72},{"i":72,"j":73,"value":73},{"i":74,"j":73,"value":73},{"i":73,"j":74,"value":74},{"i":74,"j":74,"value":74},{"i":111,"j":75,"value":75},{"i":75,"j":76,"value":76},{"i":111,"j":76,"value":76},{"i":76,"j":77,"value":77},{"i":111,"j":77,"value":77},{"i":77,"j":78,"value":78},{"i":111,"j":78,"value":78},{"i":78,"j":79,"value":79},{"i":111,"j":79,"value":79},{"i":79,"j":80,"value":80},{"i":111,"j":80,"value":80},{"i":80,"j":81,"value":81},{"i":111,"j":81,"value":81},{"i":81,"j":82,"value":82},{"i":111,"j":82,"value":82},{"i":82,"j":83,"value":83},{"i":111,"j":83,"value":83},{"i":83,"j":84,"value":84},{"i":111,"j":84,"value":84},{"i":84,"j":85,"value":85},{"i":111,"j":85,"value":85},{"i":85,"j":86,"value":86},{"i":111,"j":86,"value":86},{"i":86,"j":87,"value":87},{"i":111,"j":87,"value":87},{"i":87,"j":88,"value":88},{"i":111,"j":88,"value":88},{"i":88,"j":89,"value":89},{"i":111,"j":89,"value":89},{"i":89,"j":90,"value":90},{"i":111,"j":90,"value":90},{"i":90,"j":91,"value":91},{"i":111,"j":91,"value":91},{"i":91,"j":92,"value":92},{"i":111,"j":92,"value":92},{"i":92,"j":93,"value":93},{"i":111,"j":93,"value":93},{"i":93,"j":94,"value":94},{"i":111,"j":94,"value":94},{"i":94,"j":95,"value":95},{"i":111,"j":95,"value":95},{"i":95,"j":96,"value":96},{"i":111,"j":96,"value":96},{"i":96,"j":97,"value":97},{"i":111,"j":97,"value":97},{"i":97,"j":98,"value":98},{"i":111,"j":98,"value":98},{"i":98,"j":99,"value":99},{"i":111,"j":99,"value":99},{"i":99,"j":100,"value":100},{"i":111,"j":100,"value":100},{"i":100,"j":101,"value":101},{"i":111,"j":101,"value":101},{"i":101,"j":102,"value":102},{"i":111,"j":102,"value":102},{"i":102,"j":103,"value":103},{"i":111,"j":103,"value":103},{"i":103,"j":104,"value":104},{"i":111,"j":104,"value":104},{"i":104,"j":105,"value":105},{"i":111,"j":105,"value":105},{"i":105,"j":106,"value":106},{"i":111,"j":106,"value":106},{"i":106,"j":107,"value":107},{"i":111,"j":107,"value":107},{"i":107,"j":108,"value":108},{"i":111,"j":108,"value":108},{"i":108,"j":109,"value":109},{"i":111,"j":109,"value":109},{"i":109,"j":110,"value":110},{"i":111,"j":110,"value":110},{"i":110,"j":111,"value":111},{"i":111,"j":111,"value":111},{"i":148,"j":112,"value":112},{"i":112,"j":113,"value":113},{"i":148,"j":113,"value":113},{"i":113,"j":114,"value":114},{"i":148,"j":114,"value":114},{"i":114,"j":115,"value":115},{"i":148,"j":115,"value":115},{"i":115,"j":116,"value":116},{"i":148,"j":116,"value":116},{"i":116,"j":117,"value":117},{"i":148,"j":117,"value":117},{"i":117,"j":118,"value":118},{"i":148,"j":118,"value":118},{"i":118,"j":119,"value":119},{"i":148,"j":119,"value":119},{"i":119,"j":120,"value":120},{"i":148,"j":120,"value":120},{"i":120,"j":121,"value":121},{"i":148,"j":121,"value":121},{"i":121,"j":122,"value":122},{"i":148,"j":122,"value":122},{"i":122,"j":123,"value":123},{"i":148,"j":123,"value":123},{"i":123,"j":124,"value":124},{"i":148,"j":124,"value":124},{"i":124,"j":125,"value":125},{"i":148,"j":125,"value":125},{"i":125,"j":126,"value":126},{"i":148,"j":126,"value":126},{"i":126,"j":127,"value":127},{"i":148,"j":127,"value":127},{"i":127,"j":128,"value":128},{"i":148,"j":128,"value":128},{"i":128,"j":129,"value":129},{"i":148,"j":129,"value":129},{"i":129,"j":130,"value":130},{"i":148,"j":130,"value":130},{"i":130,"j":131,"value":131},{"i":148,"j":131,"value":131},{"i":131,"j":132,"value":132},{"i":148,"j":132,"value":132},{"i":132,"j":133,"value":133},{"i":148,"j":133,"value":133},{"i":133,"j":134,"value":134},{"i":148,"j":134,"value":134},{"i":134,"j":135,"value":135},{"i":148,"j":135,"value":135},{"i":135,"j":136,"value":136},{"i":148,"j":136,"value":136},{"i":136,"j":137,"value":137},{"i":148,"j":137,"value":137},{"i":137,"j":138,"value":138},{"i":148,"j":138,"value":138},{"i":138,"j":139,"value":139},{"i":148,"j":139,"value":139},{"i":139,"j":140,"value":140},{"i":148,"j":140,"value":140},{"i":140,"j":141,"value":141},{"i":148,"j":141,"value":141},{"i":141,"j":142,"value":142},{"i":148,"j":142,"value":142},{"i":142,"j":143,"value":143},{"i":148,"j":143,"value":143},{"i":143,"j":144,"value":144},{"i":148,"j":144,"value":144},{"i":144,"j":145,"value":145},{"i":148,"j":145,"value":145},{"i":145,"j":146,"value":146},{"i":148,"j":146,"value":146},{"i":146,"j":147,"value":147},{"i":148,"j":147,"value":147},{"i":147,"j":148,"value":148},{"i":148,"j":148,"value":148},{"i":186,"j":149,"value":149},{"i":149,"j":150,"value":150},{"i":186,"j":150,"value":150},{"i":150,"j":151,"value":151},{"i":186,"j":151,"value":151},{"i":151,"j":152,"value":152},{"i":186,"j":152,"value":152},{"i":152,"j":153,"value":153},{"i":186,"j":153,"value":153},{"i":153,"j":154,"value":154},{"i":186,"j":154,"value":154},{"i":154,"j":155,"value":155},{"i":186,"j":155,"value":155},{"i":155,"j":156,"value":156},{"i":186,"j":156,"value":156},{"i":156,"j":157,"value":157},{"i":186,"j":157,"value":157},{"i":157,"j":158,"value":158},{"i":186,"j":158,"value":158},{"i":158,"j":159,"value":159},{"i":186,"j":159,"value":159},{"i":159,"j":160,"value":160},{"i":186,"j":160,"value":160},{"i":160,"j":161,"value":161},{"i":186,"j":161,"value":161},{"i":161,"j":162,"value":162},{"i":186,"j":162,"value":162},{"i":162,"j":163,"value":163},{"i":186,"j":163,"value":163},{"i":163,"j":164,"value":164},{"i":186,"j":164,"value":164},{"i":164,"j":165,"value":165},{"i":186,"j":165,"value":165},{"i":165,"j":166,"value":166},{"i":186,"j":166,"value":166},{"i":166,"j":167,"value":167},{"i":186,"j":167,"value":167},{"i":167,"j":168,"value":168},{"i":186,"j":168,"value":168},{"i":168,"j":169,"value":169},{"i":186,"j":169,"value":169},{"i":169,"j":170,"value":170},{"i":186,"j":170,"value":170},{"i":170,"j":171,"value":171},{"i":186,"j":171,"value":171},{"i":171,"j":172,"value":172},{"i":186,"j":172,"value":172},{"i":172,"j":173,"value":173},{"i":186,"j":173,"value":173},{"i":173,"j":174,"value":174},{"i":186,"j":174,"value":174},{"i":174,"j":175,"value":175},{"i":186,"j":175,"value":175},{"i":175,"j":176,"value":176},{"i":186,"j":176,"value":176},{"i":176,"j":177,"value":177},{"i":186,"j":177,"value":177},{"i":177,"j":178,"value":178},{"i":186,"j":178,"value":178},{"i":178,"j":179,"value":179},{"i":186,"j":179,"value":179},{"i":179,"j":180,"value":180},{"i":186,"j":180,"value":180},{"i":180,"j":181,"value":181},{"i":186,"j":181,"value":181},{"i":181,"j":182,"value":182},{"i":186,"j":182,"value":182},{"i":182,"j":183,"value":183},{"i":186,"j":183,"value":183},{"i":183,"j":184,"value":184},{"i":186,"j":184,"value":184},{"i":184,"j":185,"value":185},{"i":186,"j":185,"value":185},{"i":185,"j":186,"value":186},{"i":186,"j":186,"value":186},{"i":224,"j":187,"value":187},{"i":187,"j":188,"value":188},{"i":224,"j":188,"value":188},{"i":188,"j":189,"value":189},{"i":224,"j":189,"value":189},{"i":189,"j":190,"value":190},{"i":224,"j":190,"value":190},{"i":190,"j":191,"value":191},{"i":224,"j":191,"value":191},{"i":191,"j":192,"value":192},{"i":224,"j":192,"value":192},{"i":192,"j":193,"value":193},{"i":224,"j":193,"value":193},{"i":193,"j":194,"value":194},{"i":224,"j":194,"value":194},{"i":194,"j":195,"value":195},{"i":224,"j":195,"value":195},{"i":195,"j":196,"value":196},{"i":224,"j":196,"value":196},{"i":196,"j":197,"value":197},{"i":224,"j":197,"value":197},{"i":197,"j":198,"value":198},{"i":224,"j":198,"value":198},{"i":198,"j":199,"value":199},{"i":224,"j":199,"value":199},{"i":199,"j":200,"value":200},{"i":224,"j":200,"value":200},{"i":200,"j":201,"value":201},{"i":224,"j":201,"value":201},{"i":201,"j":202,"value":202},{"i":224,"j":202,"value":202},{"i":202,"j":203,"value":203},{"i":224,"j":203,"value":203},{"i":203,"j":204,"value":204},{"i":224,"j":204,"value":204},{"i":204,"j":205,"value":205},{"i":224,"j":205,"value":205},{"i":205,"j":206,"value":206},{"i":224,"j":206,"value":206},{"i":206,"j":207,"value":207},{"i":224,"j":207,"value":207},{"i":207,"j":208,"value":208},{"i":224,"j":208,"value":208},{"i":208,"j":209,"value":209},{"i":224,"j":209,"value":209},{"i":209,"j":210,"value":210},{"i":224,"j":210,"value":210},{"i":210,"j":211,"value":211},{"i":224,"j":211,"value":211},{"i":211,"j":212,"value":212},{"i":224,"j":212,"value":212},{"i":212,"j":213,"value":213},{"i":224,"j":213,"value":213},{"i":213,"j":214,"value":214},{"i":224,"j":214,"value":214},{"i":214,"j":215,"value":215},{"i":224,"j":215,"value":215},{"i":215,"j":216,"value":216},{"i":224,"j":216,"value":216},{"i":216,"j":217,"value":217},{"i":224,"j":217,"value":217},{"i":217,"j":218,"value":218},{"i":224,"j":218,"value":218},{"i":218,"j":219,"value":219},{"i":224,"j":219,"value":219},{"i":219,"j":220,"value":220},{"i":224,"j":220,"value":220},{"i":220,"j":221,"value":221},{"i":224,"j":221,"value":221},{"i":221,"j":222,"value":222},{"i":224,"j":222,"value":222},{"i":222,"j":223,"value":223},{"i":224,"j":223,"value":223},{"i":223,"j":224,"value":224},{"i":224,"j":224,"value":224},{"i":262,"j":225,"value":225},{"i":225,"j":226,"value":226},{"i":262,"j":226,"value":226},{"i":226,"j":227,"value":227},{"i":262,"j":227,"value":227},{"i":227,"j":228,"value":228},{"i":262,"j":228,"value":228},{"i":228,"j":229,"value":229},{"i":262,"j":229,"value":229},{"i":229,"j":230,"value":230},{"i":262,"j":230,"value":230},{"i":230,"j":231,"value":231},{"i":262,"j":231,"value":231},{"i":231,"j":232,"value":232},{"i":262,"j":232,"value":232},{"i":232,"j":233,"value":233},{"i":262,"j":233,"value":233},{"i":233,"j":234,"value":234},{"i":262,"j":234,"value":234},{"i":234,"j":235,"value":235},{"i":262,"j":235,"value":235},{"i":235,"j":236,"value":236},{"i":262,"j":236,"value":236},{"i":236,"j":237,"value":237},{"i":262,"j":237,"value":237},{"i":237,"j":238,"value":238},{"i":262,"j":238,"value":238},{"i":238,"j":239,"value":239},{"i":262,"j":239,"value":239},{"i":239,"j":240,"value":240},{"i":262,"j":240,"value":240},{"i":240,"j":241,"value":241},{"i":262,"j":241,"value":241},{"i":241,"j":242,"value":242},{"i":262,"j":242,"value":242},{"i":242,"j":243,"value":243},{"i":262,"j":243,"value":243},{"i":243,"j":244,"value":244},{"i":262,"j":244,"value":244},{"i":244,"j":245,"value":245},{"i":262,"j":245,"value":245},{"i":245,"j":246,"value":246},{"i":262,"j":246,"value":246},{"i":246,"j":247,"value":247},{"i":262,"j":247,"value":247},{"i":247,"j":248,"value":248},{"i":262,"j":248,"value":248},{"i":248,"j":249,"value":249},{"i":262,"j":249,"value":249},{"i":249,"j":250,"value":250},{"i":262,"j":250,"value":250},{"i":250,"j":251,"value":251},{"i":262,"j":251,"value":251},{"i":251,"j":252,"value":252},{"i":262,"j":252,"value":252},{"i":252,"j":253,"value":253},{"i":262,"j":253,"value":253},{"i":253,"j":254,"value":254},{"i":262,"j":254,"value":254},{"i":254,"j":255,"value":255},{"i":262,"j":255,"value":255},{"i":255,"j":256,"value":256},{"i":262,"j":256,"value":256},{"i":256,"j":257,"value":257},{"i":262,"j":257,"value":257},{"i":257,"j":258,"value":258},{"i":262,"j":258,"value":258},{"i":258,"j":259,"value":259},{"i":262,"j":259,"value":259},{"i":259,"j":260,"value":260},{"i":262,"j":260,"value":260},{"i":260,"j":261,"value":261},{"i":262,"j":261,"value":261},{"i":261,"j":262,"value":262},{"i":262,"j":262,"value":262},{"i":300,"j":263,"value":263},{"i":263,"j":264,"value":264},{"i":300,"j":264,"value":264},{"i":264,"j":265,"value":265},{"i":300,"j":265,"value":265},{"i":265,"j":266,"value":266},{"i":300,"j":266,"value":266},{"i":266,"j":267,"value":267},{"i":300,"j":267,"value":267},{"i":267,"j":268,"value":268},{"i":300,"j":268,"value":268},{"i":268,"j":269,"value":269},{"i":300,"j":269,"value":269},{"i":269,"j":270,"value":270},{"i":300,"j":270,"value":270},{"i":270,"j":271,"value":271},{"i":300,"j":271,"value":271},{"i":271,"j":272,"value":272},{"i":300,"j":272,"value":272},{"i":272,"j":273,"value":273},{"i":300,"j":273,"value":273},{"i":273,"j":274,"value":274},{"i":300,"j":274,"value":274},{"i":274,"j":275,"value":275},{"i":300,"j":275,"value":275},{"i":275,"j":276,"value":276},{"i":300,"j":276,"value":276},{"i":276,"j":277,"value":277},{"i":300,"j":277,"value":277},{"i":277,"j":278,"value":278},{"i":300,"j":278,"value":278},{"i":278,"j":279,"value":279},{"i":300,"j":279,"value":279},{"i":279,"j":280,"value":280},{"i":300,"j":280,"value":280},{"i":280,"j":281,"value":281},{"i":300,"j":281,"value":281},{"i":281,"j":282,"value":282},{"i":300,"j":282,"value":282},{"i":282,"j":283,"value":283},{"i":300,"j":283,"value":283},{"i":283,"j":284,"value":284},{"i":300,"j":284,"value":284},{"i":284,"j":285,"value":285},{"i":300,"j":285,"value":285},{"i":285,"j":286,"value":286},{"i":300,"j":286,"value":286},{"i":286,"j":287,"value":287},{"i":300,"j":287,"value":287},{"i":287,"j":288,"value":288},{"i":300,"j":288,"value":288},{"i":288,"j":289,"value":289},{"i":300,"j":289,"value":289},{"i":289,"j":290,"value":290},{"i":300,"j":290,"value":290},{"i":290,"j":291,"value":291},{"i":300,"j":291,"value":291},{"i":291,"j":292,"value":292},{"i":300,"j":292,"value":292},{"i":292,"j":293,"value":293},{"i":300,"j":293,"value":293},{"i":293,"j":294,"value":294},{"i":300,"j":294,"value":294},{"i":294,"j":295,"value":295},{"i":300,"j":295,"value":295},{"i":295,"j":296,"value":296},{"i":300,"j":296,"value":296},{"i":296,"j":297,"value":297},{"i":300,"j":297,"value":297},{"i":297,"j":298,"value":298},{"i":300,"j":298,"value":298},{"i":298,"j":299,"value":299},{"i":300,"j":299,"value":299},{"i":299,"j":300,"value":300},{"i":300,"j":300,"value":300},{"i":0,"j":null,"value":null}]}

This version may break your browser because of the crazy amount of cells I'm rendering with SVG. I just wanted to see what the matrices looked like.

I believe I'm also doing something slightly wrong, I'm populating the off-diagonal values as if they are symmetric. I believe some of these matrices are not symemetric so it doesn't always render. This is mostly just to see what it might look like. The matrix could probably be efficiently rendered with canvas or even webgl.

I saw this list of sparse matrices and thought they could be thrown right into a d3 force layout.

I made a small script to process and host the "MM" formatted matrices to a d3 friendly JSON format.

I'd like to add more matrices from the list, and try to adapt this to webgl.

Built with blockbuilder.org

forked from enjalot's block: sparse matrix zoo: canvas

forked from enjalot's block: sparse matrix zoo: canvas

{"info":"%-------------------------------------------------------------------------------\n%%MatrixMarket matrix coordinate pattern symmetric\n%-------------------------------------------------------------------------------\n% UF Sparse Matrix Collection, Tim Davis\n% http://www.cise.ufl.edu/research/sparse/matrices/HB/can_61\n% name: HB/can_61\n% [SYMMETRIC PATTERN FROM CANNES,LUCIEN MARRO,JUNE 1981.]\n% id: 102\n% date: 1981\n% author: L. Marro\n% ed: I. Duff, R. Grimes, J. Lewis\n% fields: title A name id date author ed kind\n% kind: structural problem\n","meta":{"rows":"61","cols":"61","value":"61","rowIndex":"source","colIndex":"target"},"data":[{"source":1,"target":1,"value":1},{"source":14,"target":1,"value":1},{"source":16,"target":1,"value":1},{"source":20,"target":1,"value":1},{"source":24,"target":1,"value":1},{"source":25,"target":1,"value":1},{"source":2,"target":2,"value":2},{"source":4,"target":2,"value":2},{"source":14,"target":2,"value":2},{"source":15,"target":2,"value":2},{"source":21,"target":2,"value":2},{"source":22,"target":2,"value":2},{"source":26,"target":2,"value":2},{"source":27,"target":2,"value":2},{"source":28,"target":2,"value":2},{"source":3,"target":3,"value":3},{"source":4,"target":3,"value":3},{"source":16,"target":3,"value":3},{"source":17,"target":3,"value":3},{"source":31,"target":3,"value":3},{"source":32,"target":3,"value":3},{"source":33,"target":3,"value":3},{"source":35,"target":3,"value":3},{"source":36,"target":3,"value":3},{"source":4,"target":4,"value":4},{"source":5,"target":4,"value":4},{"source":7,"target":4,"value":4},{"source":14,"target":4,"value":4},{"source":15,"target":4,"value":4},{"source":16,"target":4,"value":4},{"source":17,"target":4,"value":4},{"source":21,"target":4,"value":4},{"source":22,"target":4,"value":4},{"source":25,"target":4,"value":4},{"source":26,"target":4,"value":4},{"source":27,"target":4,"value":4},{"source":28,"target":4,"value":4},{"source":29,"target":4,"value":4},{"source":31,"target":4,"value":4},{"source":32,"target":4,"value":4},{"source":33,"target":4,"value":4},{"source":34,"target":4,"value":4},{"source":35,"target":4,"value":4},{"source":36,"target":4,"value":4},{"source":37,"target":4,"value":4},{"source":38,"target":4,"value":4},{"source":41,"target":4,"value":4},{"source":5,"target":5,"value":5},{"source":7,"target":5,"value":5},{"source":8,"target":5,"value":5},{"source":15,"target":5,"value":5},{"source":23,"target":5,"value":5},{"source":28,"target":5,"value":5},{"source":29,"target":5,"value":5},{"source":30,"target":5,"value":5},{"source":34,"target":5,"value":5},{"source":37,"target":5,"value":5},{"source":38,"target":5,"value":5},{"source":39,"target":5,"value":5},{"source":43,"target":5,"value":5},{"source":6,"target":6,"value":6},{"source":7,"target":6,"value":6},{"source":17,"target":6,"value":6},{"source":18,"target":6,"value":6},{"source":40,"target":6,"value":6},{"source":41,"target":6,"value":6},{"source":42,"target":6,"value":6},{"source":44,"target":6,"value":6},{"source":45,"target":6,"value":6},{"source":7,"target":7,"value":7},{"source":8,"target":7,"value":7},{"source":10,"target":7,"value":7},{"source":17,"target":7,"value":7},{"source":18,"target":7,"value":7},{"source":34,"target":7,"value":7},{"source":36,"target":7,"value":7},{"source":37,"target":7,"value":7},{"source":38,"target":7,"value":7},{"source":39,"target":7,"value":7},{"source":40,"target":7,"value":7},{"source":41,"target":7,"value":7},{"source":42,"target":7,"value":7},{"source":43,"target":7,"value":7},{"source":44,"target":7,"value":7},{"source":45,"target":7,"value":7},{"source":46,"target":7,"value":7},{"source":47,"target":7,"value":7},{"source":50,"target":7,"value":7},{"source":8,"target":8,"value":8},{"source":10,"target":8,"value":8},{"source":11,"target":8,"value":8},{"source":38,"target":8,"value":8},{"source":39,"target":8,"value":8},{"source":43,"target":8,"value":8},{"source":46,"target":8,"value":8},{"source":47,"target":8,"value":8},{"source":48,"target":8,"value":8},{"source":52,"target":8,"value":8},{"source":9,"target":9,"value":9},{"source":10,"target":9,"value":9},{"source":18,"target":9,"value":9},{"source":19,"target":9,"value":9},{"source":49,"target":9,"value":9},{"source":50,"target":9,"value":9},{"source":51,"target":9,"value":9},{"source":53,"target":9,"value":9},{"source":54,"target":9,"value":9},{"source":10,"target":10,"value":10},{"source":11,"target":10,"value":10},{"source":13,"target":10,"value":10},{"source":18,"target":10,"value":10},{"source":19,"target":10,"value":10},{"source":43,"target":10,"value":10},{"source":45,"target":10,"value":10},{"source":46,"target":10,"value":10},{"source":47,"target":10,"value":10},{"source":48,"target":10,"value":10},{"source":49,"target":10,"value":10},{"source":50,"target":10,"value":10},{"source":51,"target":10,"value":10},{"source":52,"target":10,"value":10},{"source":53,"target":10,"value":10},{"source":54,"target":10,"value":10},{"source":55,"target":10,"value":10},{"source":56,"target":10,"value":10},{"source":59,"target":10,"value":10},{"source":11,"target":11,"value":11},{"source":13,"target":11,"value":11},{"source":47,"target":11,"value":11},{"source":48,"target":11,"value":11},{"source":52,"target":11,"value":11},{"source":55,"target":11,"value":11},{"source":56,"target":11,"value":11},{"source":57,"target":11,"value":11},{"source":61,"target":11,"value":11},{"source":12,"target":12,"value":12},{"source":13,"target":12,"value":12},{"source":19,"target":12,"value":12},{"source":58,"target":12,"value":12},{"source":59,"target":12,"value":12},{"source":60,"target":12,"value":12},{"source":13,"target":13,"value":13},{"source":19,"target":13,"value":13},{"source":52,"target":13,"value":13},{"source":54,"target":13,"value":13},{"source":55,"target":13,"value":13},{"source":56,"target":13,"value":13},{"source":57,"target":13,"value":13},{"source":58,"target":13,"value":13},{"source":59,"target":13,"value":13},{"source":60,"target":13,"value":13},{"source":61,"target":13,"value":13},{"source":14,"target":14,"value":14},{"source":16,"target":14,"value":14},{"source":20,"target":14,"value":14},{"source":21,"target":14,"value":14},{"source":24,"target":14,"value":14},{"source":25,"target":14,"value":14},{"source":26,"target":14,"value":14},{"source":27,"target":14,"value":14},{"source":32,"target":14,"value":14},{"source":15,"target":15,"value":15},{"source":22,"target":15,"value":15},{"source":23,"target":15,"value":15},{"source":27,"target":15,"value":15},{"source":28,"target":15,"value":15},{"source":29,"target":15,"value":15},{"source":30,"target":15,"value":15},{"source":34,"target":15,"value":15},{"source":16,"target":16,"value":16},{"source":20,"target":16,"value":16},{"source":24,"target":16,"value":16},{"source":25,"target":16,"value":16},{"source":26,"target":16,"value":16},{"source":31,"target":16,"value":16},{"source":32,"target":16,"value":16},{"source":33,"target":16,"value":16},{"source":17,"target":17,"value":17},{"source":33,"target":17,"value":17},{"source":35,"target":17,"value":17},{"source":36,"target":17,"value":17},{"source":37,"target":17,"value":17},{"source":40,"target":17,"value":17},{"source":41,"target":17,"value":17},{"source":42,"target":17,"value":17},{"source":18,"target":18,"value":18},{"source":42,"target":18,"value":18},{"source":44,"target":18,"value":18},{"source":45,"target":18,"value":18},{"source":46,"target":18,"value":18},{"source":49,"target":18,"value":18},{"source":50,"target":18,"value":18},{"source":51,"target":18,"value":18},{"source":19,"target":19,"value":19},{"source":51,"target":19,"value":19},{"source":53,"target":19,"value":19},{"source":54,"target":19,"value":19},{"source":55,"target":19,"value":19},{"source":58,"target":19,"value":19},{"source":59,"target":19,"value":19},{"source":60,"target":19,"value":19},{"source":20,"target":20,"value":20},{"source":24,"target":20,"value":20},{"source":25,"target":20,"value":20},{"source":21,"target":21,"value":21},{"source":26,"target":21,"value":21},{"source":27,"target":21,"value":21},{"source":22,"target":22,"value":22},{"source":27,"target":22,"value":22},{"source":28,"target":22,"value":22},{"source":23,"target":23,"value":23},{"source":29,"target":23,"value":23},{"source":30,"target":23,"value":23},{"source":24,"target":24,"value":24},{"source":25,"target":24,"value":24},{"source":25,"target":25,"value":25},{"source":26,"target":25,"value":25},{"source":32,"target":25,"value":25},{"source":26,"target":26,"value":26},{"source":27,"target":26,"value":26},{"source":32,"target":26,"value":26},{"source":27,"target":27,"value":27},{"source":28,"target":27,"value":27},{"source":28,"target":28,"value":28},{"source":29,"target":28,"value":28},{"source":34,"target":28,"value":28},{"source":29,"target":29,"value":29},{"source":30,"target":29,"value":29},{"source":34,"target":29,"value":29},{"source":30,"target":30,"value":30},{"source":31,"target":31,"value":31},{"source":32,"target":31,"value":31},{"source":33,"target":31,"value":31},{"source":32,"target":32,"value":32},{"source":33,"target":32,"value":32},{"source":33,"target":33,"value":33},{"source":35,"target":33,"value":33},{"source":36,"target":33,"value":33},{"source":34,"target":34,"value":34},{"source":37,"target":34,"value":34},{"source":38,"target":34,"value":34},{"source":35,"target":35,"value":35},{"source":36,"target":35,"value":35},{"source":36,"target":36,"value":36},{"source":37,"target":36,"value":36},{"source":41,"target":36,"value":36},{"source":37,"target":37,"value":37},{"source":38,"target":37,"value":37},{"source":41,"target":37,"value":37},{"source":38,"target":38,"value":38},{"source":39,"target":38,"value":38},{"source":43,"target":38,"value":38},{"source":39,"target":39,"value":39},{"source":43,"target":39,"value":39},{"source":40,"target":40,"value":40},{"source":41,"target":40,"value":40},{"source":42,"target":40,"value":40},{"source":41,"target":41,"value":41},{"source":42,"target":41,"value":41},{"source":42,"target":42,"value":42},{"source":44,"target":42,"value":42},{"source":45,"target":42,"value":42},{"source":43,"target":43,"value":43},{"source":46,"target":43,"value":43},{"source":47,"target":43,"value":43},{"source":44,"target":44,"value":44},{"source":45,"target":44,"value":44},{"source":45,"target":45,"value":45},{"source":46,"target":45,"value":45},{"source":50,"target":45,"value":45},{"source":46,"target":46,"value":46},{"source":47,"target":46,"value":46},{"source":50,"target":46,"value":46},{"source":47,"target":47,"value":47},{"source":48,"target":47,"value":47},{"source":52,"target":47,"value":47},{"source":48,"target":48,"value":48},{"source":52,"target":48,"value":48},{"source":49,"target":49,"value":49},{"source":50,"target":49,"value":49},{"source":51,"target":49,"value":49},{"source":50,"target":50,"value":50},{"source":51,"target":50,"value":50},{"source":51,"target":51,"value":51},{"source":53,"target":51,"value":51},{"source":54,"target":51,"value":51},{"source":52,"target":52,"value":52},{"source":55,"target":52,"value":52},{"source":56,"target":52,"value":52},{"source":53,"target":53,"value":53},{"source":54,"target":53,"value":53},{"source":54,"target":54,"value":54},{"source":55,"target":54,"value":54},{"source":59,"target":54,"value":54},{"source":55,"target":55,"value":55},{"source":56,"target":55,"value":55},{"source":59,"target":55,"value":55},{"source":56,"target":56,"value":56},{"source":57,"target":56,"value":56},{"source":61,"target":56,"value":56},{"source":57,"target":57,"value":57},{"source":61,"target":57,"value":57},{"source":58,"target":58,"value":58},{"source":59,"target":58,"value":58},{"source":60,"target":58,"value":58},{"source":59,"target":59,"value":59},{"source":60,"target":59,"value":59},{"source":60,"target":60,"value":60},{"source":61,"target":61,"value":61},{"source":0,"target":null,"value":null}]}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="matrix.js"></script>
<style>
body {
margin:0;position:fixed;top:0;right:0;bottom:0;left:0;
background-color: #111;
overflow: scroll;
}
svg.force {
width: 480px; height: 100%;
position:absolute;
left: 0px
}
svg.matrix {
height: 100%;
left: 500px;
top: 40px;
position: absolute;
}
canvas {
position:absolute;
}
line {
pointer-events: none;
}
#matrices {
position: absolute;
top: 10px;
left: 10px;
}
</style>
</head>
<body>
<canvas></canvas>
<svg class="force"></svg>
<svg class="matrix"></svg>
<select id="matrices"></select>
<script>
var width = 960/2;
var height = window.innerHeight || 500;
var canvas = d3.select("canvas").node();
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext("2d");
ctx.globalCompositeOperation = "lighter";
var color = "#8effe8";
var mcolor = d3.scale.linear()
.range(["#232323", color])
d3.json("http://enjalot.github.io/sparse-matrix-zoo/json/list.json", function(err, matrices) {
var startingIndex = 2;
var select = d3.select("#matrices")
select.selectAll("option")
.data(matrices)
.enter().append("option")
.text(function(d) { return d.name })
.filter(function(d,i) { return i == startingIndex })
.attr("selected", true)
select.on("change", function() {
var i = this.selectedIndex;
render(matrices[i].url);
})
render(matrices[startingIndex].url)
var force;
function render(url) {
//var url = "http://enjalot.github.io/sparse-matrix-zoo/json/can_61.json";
d3.json(url, function(err, data) {
console.log(data);
var numNodes = d3.max([+data.meta.rows, +data.meta.cols]);
console.log("numNodes", numNodes);
var nodes = d3.range(numNodes).map(function(d) { return {i: d, value: 0}});
var links = []
data.data.forEach(function(d) {
if(d.source !== d.target) {
// the matrix is 1-indexed
links.push(d)
} else {
nodes[d.source].value = d.value
}
})
console.log("nodes", nodes)
console.log("links",links)
var linkExtent = d3.extent(links, function(d) { return d.value })
var linkScale = d3.scale.sqrt()
.domain(linkExtent)
.range([1, 10])
var nodeExtent = d3.extent(nodes, function(d) { return d.value })
var nodeScale = d3.scale.sqrt()
.domain(nodeExtent)
.range([3, 8])
var colorExtent = d3.extent(linkExtent.concat(nodeExtent).concat([0]))
mcolor.domain(colorExtent)
delete force;
force = d3.layout.force()
.charge(-180)
.linkDistance(40)
.friction(0.8)
.gravity(0.2)
//.linkStrength(0.9)
.linkStrength(function(d) { return linkScale(d.value)/10 })
.size([width, height]);
force
.nodes(nodes)
.links(links)
.start();
function draw() {
ctx.clearRect(0, 0, width, height);
ctx.strokeStyle = "rgba(142, 255, 232, 0.2)";
ctx.lineCap = "round";
links.forEach(function(l) {
ctx.beginPath();
ctx.lineWidth = linkScale(l.value);
ctx.moveTo(l.source.x, l.source.y);
ctx.lineTo(l.target.x, l.target.y);
ctx.stroke();
})
}
var svg = d3.select("svg.force");
var node = svg.selectAll(".node")
.data(nodes)
node.exit().remove();
node
.enter().append("circle")
.attr("class", "node")
.style("fill", function(d) { return color })
node
//.attr("r", 5)
.attr("r", function(d) { return nodeScale(d.value) })
.call(force.drag);
force.on("tick", function() {
draw();
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
});
var size = 4;
var margin = [1, 1];
var msvg = d3.select("svg.matrix")
// make sure the matrix fits in the svg
.style("width", +data.meta.cols * (size + margin[0]) + 100)
var A = d3.range(+data.meta.rows).map(function(i) {
return d3.range(+data.meta.cols).map(function(j) {
return 0;
})
})
nodes.forEach(function(d) {
A[d.i][d.i] = d.value;
})
links.forEach(function(d) {
A[d.source.i][d.target.i] = d.value;
A[d.target.i][d.source.i] = d.value;
})
var matrix = new d3.svg.matrix()
.data(A)
.cellWidth(size)
.cellHeight(size)
.margin(margin)
matrix.update(msvg) // render the matrix
msvg.selectAll("rect.bg")
.style({
fill: function(d) {
return mcolor(d.data);
}
})
.on("click", function(d) {
console.log(d);
})
})
}
})
</script>
</body>
d3.layout.matrix = matrixLayout;
d3.svg.matrix = matrixComponent;
function matrixComponent() {
var g;
var data = [[]];
var mapping = [[]];
var nodes = [];
var layout = d3.layout.matrix();
var margin = layout.margin();
var cellWidth = layout.cellWidth();
var cellHeight = layout.cellHeight();
/*
TODO
make scrubbing configurable, per-cell
*/
var dispatch = d3.dispatch("change")
this.update = function(group) {
if(group) g = group;
nodes = layout.nodes(data);
var line = d3.svg.line()
.x(function(d) { return d[0] })
.y(function(d) { return d[1] })
var brackets = g.selectAll("path.bracket")
.data([1, -1])
brackets.enter().append("path").classed("bracket", true)
.attr("d", function(d) {
var nRows = data.length;
var x0 = d * cellWidth/4;
var x1 = -margin[0]/2;
var y0 = -margin[1]/2;
var y1 = (cellHeight + margin[1]) * nRows - margin[1]/2
if(d === 1) {
return line([
[x0, y0],
[x1, y0],
[x1, y1],
[x0, y1]
])
} else {
var dx = (cellWidth + margin[0]) * data[0].length - margin[0]/2
x0 -= margin[0]/2
return line([
[x0 + dx, y0],
[dx, y0],
[dx, y1],
[x0 + dx, y1]
])
}
}).attr({
stroke: "#111",
fill: "none"
})
var cells = g.selectAll("g.number")
.data(nodes, function(d) { return d.index })
cells.exit().remove();
var enter = cells.enter().append("g").classed("number", true)
enter.append("rect").classed("bg", true)
cells.select("rect.bg")
.attr({
width: cellWidth,
height: cellHeight,
x: function(d) { return d.x },
y: function(d) { return d.y },
fill: "#fff"
})
/*
enter.append("text")
cells.select("text").attr({
x: function(d) { return d.x + cellWidth/2 },
y: function(d) { return d.y + cellHeight/2 },
"alignment-baseline": "middle",
"text-anchor": "middle",
"line-height": cellHeight,
"fill": "#091242"
}).text(function(d) { return d.data })
*/
/*
var step = 0.1;
var that = this;
var drag = d3.behavior.drag()
.on("drag", function(d) {
var oldData = d.data;
var val = d.data + d3.event.dx * step
val = +(Math.round(val*10)/10).toFixed(1)
set(val, d.i, d.j);
//data[d.i][d.j] = val;
that.update()
dispatch.change(d, oldData)
})
cells.call(drag)
*/
return this;
}
function set(val, i, j) {
var m = mapping[i][j];
if(m){
mapping.forEach(function(row, mi) {
row.forEach(function(col, mj) {
if(col === m) {
data[mi][mj] = val;
}
})
})
}
data[i][j] = val;
}
this.mapping = function(val) {
if(val) {
// TODO make sure dims match
mapping = val;
return this;
}
return mapping;
}
this.data = function(val) {
if(val) {
data = val;
nodes = layout.nodes(data);
return this;
}
return data;
}
this.margin = function(val) {
if(val) {
margin = val;
layout.margin(margin);
return this;
}
return margin;
}
this.cellWidth = function(val) {
if(val) {
cellWidth = val;
layout.cellWidth(cellWidth);
return this;
}
return cellWidth;
}
this.cellHeight = function(val) {
if(val) {
cellHeight = val;
layout.cellHeight(cellHeight);
return this;
}
return cellHeight;
}
d3.rebind(this, dispatch, "on")
return this;
}
function matrixLayout() {
/*
We accept our matrix data as a list of rows:
[ [a, b],
[c, d] ]
*/
var data = [[]];
var nodes;
var margin = [0, 0];
var cellWidth = 20;
var cellHeight = 20;
var nRows;
function getX(i) {
return i * (cellWidth + margin[0])
}
function getY(j) {
return j * (cellHeight + margin[1])
}
function newNodes() {
nRows = data.length;
nodes = [];
data.forEach(function(rows,i) {
rows.forEach(function(col, j) {
var node = {
x: getX(j),
y: getY(i),
data: col,
i: i,
j: j,
index: i * nRows + j
}
nodes.push(node);
})
})
}
function calculate() {
nRows = data.length;
data.forEach(function(rows,i) {
rows.forEach(function(col, j) {
var node = nodes[i * nRows + j];
if(!node) return;
node.data = col;
node.x = getX(j);
node.y = getY(i);
})
})
}
this.nodes = function(val) {
if(val) {
this.data(val);
}
return nodes;
}
this.data = function(val) {
if(val) {
if(val.length === data.length && val[0].length === data[0].length) {
// if the same size matrix is being updated,
// just update the values by reference
// the positions shouldn't change
data = val;
calculate();
} else {
data = val;
newNodes();
}
nRows = data.length;
return this;
}
return data;
}
this.margin = function(val) {
if(val) {
margin = val;
calculate();
return this;
}
return margin;
}
this.cellWidth = function(val) {
if(val) {
cellWidth = val;
calculate();
return this;
}
return cellWidth;
}
this.cellHeight = function(val) {
if(val) {
cellHeight = val
calculate();
return this;
}
return cellHeight;
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment