def ClusteringCoefNodesDontExist_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) obs = G.clustering_coef(['Lexa', 'Roy', 'Demmi']) exp = {} assert_equal(exp, obs)
def clustCoefempty_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # give an empty list obs = G.clustering_coef(node_list=[]) exp = {} assert_equal(exp, obs)
def emptyEdges_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # test "edges" when given a string and not a list of strings obs = G.edges('Alex') exp = [['Alex', 'Julie'], ['Alex', 'Michael'], ['Alex', 'Ved']] assert_equal(exp, obs)
def degreeNodeList(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # give and empty list obs = G.degree(node_L=[]) exp = False assert_equal(exp, obs)
def hasNodeEmpty_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # given an empty list to "has_node" should return empty list exp = False obs = G.has_node([]) assert_equal(exp, obs)
def neighborsNoNode_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # give empty list obs = G.neighbors([]) # need to figure how to capture standard out exp = False assert_equal(exp, obs)
def removeEmptyStr_test(): # try to remove a node but user gives an empty string G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) G.remove_node('') exp = {'Alex', 'Julie', 'Rob', 'Ved', 'Michael', 'Mark', 'Jeff'} obs = G.nodes() assert_equal(exp, obs)
def removePartEdge_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) exp = G.edges() # remove an edge but give a single part of the edge G.remove_edge(['Alex']) obs = G.edges() assert_equal(exp, obs)
def removeEdgeMorethan2_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # remove an edge but give three entries G.remove_edge(['Alex', 'Julie', 'Michael']) exp = 21 obs = len(G.edges()) assert_equal(exp, obs)
def removeNodeSet_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # try to remove an empty set G.remove_node({}) exp = {'Alex', 'Julie', 'Rob', 'Ved', 'Michael', 'Mark', 'Jeff'} obs = G.nodes() assert_equal(exp, obs)
def removeEmptylst_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # try and remove an empty list G.remove_node(node=[]) exp = {'Alex', 'Julie', 'Rob', 'Ved', 'Michael', 'Mark', 'Jeff'} obs = G.nodes() assert_equal(exp, obs)
def relabelNodesUneven_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) Notsame = ['A', 'B', 'C', 'D', 'E', 'F'] obs = relabel_nodes(G, Notsame) exp = False # get standard out assert_equal(exp, obs)
def addNoEdge_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) exp = G.edges() # remove an edge but give an empty list G.remove_edge([]) obs = G.edges() assert_equal(exp, obs)
def numNode_test(): # create a small graph G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) exp = {'Alex', 'Julie', 'Rob', 'Ved', 'Michael', 'Mark', 'Jeff'} obs = G.nodes() assert_equal(exp, obs)
def relabelNodesBlank_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) Blank = ['', '', '', '', '', '', ''] # give a blank list, a list with stuff, but they are all the same # and are empty character strings obs = relabel_nodes(G, Blank) exp = {'': ['', '', '']} assert_equal(exp, obs)
def Graph_setup(): Friends = ['Alex', 'Julie', 'Rob', 'Ved', 'Michael', 'Mark', 'Jeff'] Relationships = [['Alex', 'Julie'], ['Julie', 'Alex'], ['Alex', 'Michael'], ['Michael', 'Alex'], ['Julie', 'Michael'], ['Michael', 'Julie'], ['Mark', 'Michael'], ['Michael', 'Mark'], ['Jeff', 'Mark'], ['Mark', 'Jeff'], ['Ved', 'Michael'], ['Michael', 'Ved'], ['Alex', 'Ved'], ['Ved', 'Alex'], ['Ved', 'Jeff'], ['Jeff', 'Ved'], ['Ved', 'Rob'], ['Rob', 'Ved'], ['Julie', 'Rob'], ['Rob', 'Julie'], ['Rob', 'Jeff'], ['Jeff', 'Rob']] G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships)
def subgraphNoneNode_test(): G = Graph() G.add_nodes_from(Friends) G.add_edges_from(Relationships) # A node in the subgraph list does not exist in "Nodes" sub_list = ['Alex', 'Michael', 'Julie', 'Matt'] obs = subgraph(G, sub_list).G exp = { 'Alex': ['Julie', 'Michael'], 'Julie': ['Alex', 'Michael'], 'Michael': ['Alex', 'Julie', 'Ved'] } assert_equal(exp, obs)