Tags: fkling/JSNetworkX
Tags
Add generic node support and mocha test framework. The library was changed to support and respect different data types for node values. Until now, every node value was implicitly convert to a string. With this change, numbers and strings and every object implementing 'toString' can be used as node value. This is a breaking commit. The following changes have been made: - Objects used to store nodes as keys have been replaced by jsnx.contrib.Map. Every method which used to return an object of nodes (such as "G.degree()") returns a jsnx.contrib.Map now. - The method "G.get_node" was renamed to "G.get" to be closer to the jsnx.contrib.Map interface. The main difference for user code is the switch from bracket notation (i.e. "degrees[node]") to the Map interface ("degree.get(node)"). Instead of using a "for...in" loop to iterate over all values, the ".forEach" of the map object can be used. Since the test cases had to be adjusted to generic nodes, this opportunity was taken advantage of to change the testing framework from Jasmine to Mocha, which enables us to write simpler test cases.