0.0.10 • Published 8 years ago

url-graph v0.0.10

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

Build Status

Installation

Using npm:

npm install url-graph

In Node.js:

const graph = require('url-graph');

Example

make a graph from a set of urls

let urls = [
  'https://github.com/ansteh/url-graph',
  'https://github.com/lodash/lodash',
  'https://github.com/ansteh/shape-array',
  'https://github.com/sindresorhus/got',
  'https://github.com/ansteh/shape-json'
];

let domains = graph.treefy(urls);
console.log(domains);
[{
  "name":"github.com",
  "count":5,
  "branch":[{
    "name":"ansteh",
    "count":3,
    "branch":[
      {"name":"url-graph","count":1},
      {"name":"shape-array","count":1},
      {"name":"shape-json","count":1}
    ]
  },{
    "name":"lodash",
    "count":1,
    "branch":[
      {"name":"lodash","count":1}
    ]
  },{
    "name":"sindresorhus",
    "count":1,
    "branch":[
      {"name":"got","count":1}
    ]
  }]
}]

link directories

merge neighboring nodes with same count

let urls = [
  'https://github.com/ansteh/shape-json/blob/master/lib/chain.js',
  'https://github.com/ansteh/shape-json/blob/master/lib/core.js',
  'https://github.com/ansteh/shape-json/blob/master/lib/parse.js',
  'https://github.com/ansteh/shape-json/blob/master/lib/scheme.js'
];

let reducedTree = graph.linkDirectories(urls);
console.log(reducedTree);
[{
  "name":"github.com/ansteh/shape-json/blob/master/lib",
  "count":4,
  "branch":[
    { "name": "chain.js",  "count":1 },
    { "name": "core.js",   "count":1 },
    { "name": "parse.js",  "count":1 },
    { "name": "scheme.js", "count":1 }
  ]
}]

License

MIT © Andre Stehle

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago