0.0.10 • Published 9 years ago

url-graph v0.0.10

Weekly downloads
5
License
MIT
Repository
github
Last release
9 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

9 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago