netkit.graph.edgecreator
Class BaseCategoricalEdgeCreator

java.lang.Object
  extended by netkit.graph.edgecreator.EdgeCreatorImp
      extended by netkit.graph.edgecreator.BaseCategoricalEdgeCreator
All Implemented Interfaces:
EdgeCreator

public class BaseCategoricalEdgeCreator
extends EdgeCreatorImp


Nested Class Summary
 
Nested classes/interfaces inherited from class netkit.graph.edgecreator.EdgeCreatorImp
EdgeCreatorImp.NbrEntry
 
Field Summary
 
Fields inherited from class netkit.graph.edgecreator.EdgeCreatorImp
attrib, attributeIndex, attributeValue, edges, edgetype, gm, graph, logger, maxEdges, nodeType, split, trainAssortativity, trueAssortativity
 
Constructor Summary
BaseCategoricalEdgeCreator()
           
 
Method Summary
protected  void buildEdges()
          build the edges using the current edge creation model.
 boolean canHandle(Attribute attribute)
          Queries the edge creator if it can handle (i.e., create edges for) the given attribute.
 boolean canHandleAttributeValue(Attribute attribute)
          Queries the edge creator if it can handle (i.e., create edges for) the given attribute using a specific attribute value.
 double[][] getAssortativityMatrix(boolean useTrueAssort)
           
 Edge[] getEdgesToNearestNeighbors(Node node)
          Get the edges to the K nearest nodes (highest weight using this edge creator), where max-k was provided during initialization.
 java.lang.String getName()
          The name of this edge-creator
 double getWeight(Node src, Node dest)
          Calculate the edgeweight from node src to node dest.
 void initialize(Graph graph, java.lang.String nodeType, int attributeIndex, double attributeValue, int maxEdges)
          Initialize this creator.
 boolean isByAttributeValue()
          Is this edge creator by attribute value or by attribute as a whole
 
Methods inherited from class netkit.graph.edgecreator.EdgeCreatorImp
addCliqueToAssortMatrix, buildModel, createEdges, getAssortativity, getAttributeIndex, getAttributeValue, getEdgeType, getLabeledNodes, getMaxEdges, isByAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseCategoricalEdgeCreator

public BaseCategoricalEdgeCreator()
Method Detail

initialize

public void initialize(Graph graph,
                       java.lang.String nodeType,
                       int attributeIndex,
                       double attributeValue,
                       int maxEdges)
Description copied from interface: EdgeCreator
Initialize this creator. This can only be done once

Specified by:
initialize in interface EdgeCreator
Overrides:
initialize in class EdgeCreatorImp
Parameters:
graph - The graph over which to create edges
nodeType - Which nodetype is the node to create edges over
attributeIndex - The attribute index over which to generate edges (ignored for creators that cannot handle attributes)
attributeValue - The attribute value over which to generate edges (ignored for creators that cannot handle values; otherwise ignored if value is Double.NaN)
maxEdges - The maximum number of outgoing edges to create from any given node

getName

public java.lang.String getName()
Description copied from interface: EdgeCreator
The name of this edge-creator


getWeight

public double getWeight(Node src,
                        Node dest)
Description copied from interface: EdgeCreator
Calculate the edgeweight from node src to node dest. Assumes that initialize has already been called, so that the creator knows the graph, the class attribute index and the attribute index

Parameters:
src - The source node
dest - The destination node
Returns:
the weight of the edge, Double.NaN if no edge should be created.

canHandle

public boolean canHandle(Attribute attribute)
Description copied from interface: EdgeCreator
Queries the edge creator if it can handle (i.e., create edges for) the given attribute.

Returns:
true if this edge creator can create edges based on the given Attribute

canHandleAttributeValue

public boolean canHandleAttributeValue(Attribute attribute)
Description copied from interface: EdgeCreator
Queries the edge creator if it can handle (i.e., create edges for) the given attribute using a specific attribute value.

Specified by:
canHandleAttributeValue in interface EdgeCreator
Overrides:
canHandleAttributeValue in class EdgeCreatorImp
Returns:
true if this edge creator can create edges based on the given Attribute if given a specific attribute value

isByAttributeValue

public boolean isByAttributeValue()
Description copied from interface: EdgeCreator
Is this edge creator by attribute value or by attribute as a whole

Specified by:
isByAttributeValue in interface EdgeCreator
Overrides:
isByAttributeValue in class EdgeCreatorImp

getEdgesToNearestNeighbors

public Edge[] getEdgesToNearestNeighbors(Node node)
Description copied from class: EdgeCreatorImp
Get the edges to the K nearest nodes (highest weight using this edge creator), where max-k was provided during initialization. This goes through all nodes in the graph, so sub-classes should override to provide a more optimized version. This list should include all nearest neighbors, not only those in the 'training set'. It will look for a cutoff in weights less than k, but if the first k weights are all the same then it will look forward to the first cutoff. This may mean that all nodes are neighbors if all weights are the same.

Overrides:
getEdgesToNearestNeighbors in class EdgeCreatorImp
Parameters:
node - The node
Returns:

getAssortativityMatrix

public double[][] getAssortativityMatrix(boolean useTrueAssort)
Overrides:
getAssortativityMatrix in class EdgeCreatorImp

buildEdges

protected void buildEdges()
Description copied from class: EdgeCreatorImp
build the edges using the current edge creation model. If you want to use the default buildAssortativityMatrix method and if you override this method, then you must add edges such that they are grouped by source node (i.e., all edges with the same source node appear sequentially in the edges array). This assumption is leverage by the default getAssortativityMatrix method for efficiency.

Overrides:
buildEdges in class EdgeCreatorImp