

def sampleData():
    sheet1 = globs.gdoc.sheet1
    row1 = lowercaselist(sheet1.row_values(1))
    fromurldex = (row1.index('url') + 1)
    linkstodex = (row1.index('linksto') + 1)
    fromurl = sheet1.col_values(fromurldex)
    linksto = sheet1.col_values(linkstodex)
    edgetuples = zip(fromurl, linksto)
    nodes = ''
    for aurl in set(fromurl):
        if (aurl != 'url'):
            nodes = (nodes + ("{ data: { id: '%s', name: '%s'} },\n" % (aurl, aurl)))
    nodes = nodes[:(- 2)]
    edges = ''
    for atuple in edgetuples:
        if (atuple[0] != 'url'):
            edges = (edges + ("{ data: { source: '%s', target: '%s' } },\n" % (atuple[0], atuple[1])))
    edges = edges[:(- 2)]
    xnodes = "{ data: { id: 'j', name: 'j'} },\n             { data: { id: 'e', name: 'e'} },\n             { data: { id: 'k', name: 'k'} },\n             { data: { id: 'g', name: 'g'} }"
    xedges = "{ data: { source: 'j', target: 'e' } },\n        { data: { source: 'j', target: 'k' } },\n        { data: { source: 'j', target: 'g' } },\n        { data: { source: 'e', target: 'j' } },\n        { data: { source: 'e', target: 'k' } },\n        { data: { source: 'k', target: 'j' } },\n        { data: { source: 'k', target: 'e' } },\n        { data: { source: 'k', target: 'g' } },\n        { data: { source: 'g', target: 'j' } }"
    return ("$(function(){ // on dom ready\n\n  $('#cy').cytoscape({\n    style: cytoscape.stylesheet()\n      .selector('node')\n        .css({\n          'content': 'data(name)',\n          'text-valign': 'center',\n          'color': 'white',\n          'text-outline-width': 2,\n          'text-outline-color': '#888'\n        })\n      .selector('edge')\n        .css({\n          'target-arrow-shape': 'triangle'\n        })\n      .selector(':selected')\n        .css({\n          'background-color': 'black',\n          'line-color': 'black',\n          'target-arrow-color': 'black',\n          'source-arrow-color': 'black'\n        })\n      .selector('.faded')\n        .css({\n          'opacity': 0,\n          'text-opacity': 0.25\n        }),\n    \n    elements: {\n      nodes: [\n        %s\n      ],\n      edges: [\n        %s \n      ]\n    },\n    \n    layout: {\n      name: 'breadthfirst',\n      padding: 10,\n      strictHierarchy: true,\n      avoidOverlap: true\n    },\n    \n    // on graph initial layout done (could be async depending on layout...)\n    ready: function(){\n      window.cy = this;\n      \n      // giddy up...\n      \n      cy.elements().unselectify();\n      \n      cy.on('tap', 'node', function(e){\n        var node = e.cyTarget; \n        var neighborhood = node.neighborhood().add(node);\n        \n        cy.elements().addClass('faded');\n        neighborhood.removeClass('faded');\n      });\n      \n      cy.on('tap', function(e){\n        if( e.cyTarget === cy ){\n          cy.elements().removeClass('faded');\n        }\n      });\n    }\n  });\n\n  }); // on dom ready" % (nodes, edges))

dataset/ETHPy150Open miklevin/pipulate/common.py sampleData/original