My Project
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CommonKnowledge Class Reference

Public Member Functions

Map< KnowledgeField, CommonKnowledgeDatagetKnowledgeFields ()
 
void updateField (KnowledgeField kf, int delta_n)
 
int getNumInstancesOfField (KnowledgeField kf)
 
double getPerformance (KnowledgeField kf)
 
void updatePerformance ()
 

Private Member Functions

boolean containsKF (KnowledgeField kf)
 
KnowledgeField getAlterEgo (KnowledgeField kf)
 
void computeRandomPerformance ()
 
void computeBetweenness ()
 
int setupGraphAndGetNumCN (UndirectedSparseGraph graph)
 

Private Attributes

HashMap< KnowledgeField, CommonKnowledgeDataknowledgeFields
 
boolean mapsChanged
 

Detailed Description

Contains the number of instances of each knowledge field. Contains a method to compute betweeness centrality.

Author
Sirio Capizzi
Guido Fioretti
Ruggero Rossi

Member Function Documentation

void CommonKnowledge.computeBetweenness ( )
inlineprivate

Computes the Betweeness Centrality. Employs the library http://jung.sourceforge.net. Based on: Ulrik Brandes, "A Faster Algorithm for Betweeness Centrality". Journal of Mathematical Sociology, 25(2): 163-177, 2001.

See original paper: http://www.algo.uni-konstanz.de/publications/b-fabc-01.pdf

In graph theory, betweenness centrality is a measure of centrality in a graph based on shortest paths. For every pair of vertices in a connected graph, there exists at least one shortest path between the vertices such that either the number of edges that the path passes through (for unweighted graphs) or the sum of the weights of the edges (for weighted graphs) is minimized. The betweenness centrality for each vertex is the number of these shortest paths that pass through the vertex.

Read more here: https://en.wikipedia.org/wiki/Betweenness_centrality

Computes betweenness centrality for each vertex and edge in the graph. The result is that each vertex and edge has a UserData element of type MutableDouble whose key is 'centrality.BetweennessCentrality'. Note: Many social network researchers like to normalize the betweenness values by dividing the values by (n-1)(n-2)/2. The values given here are unnormalized.

void CommonKnowledge.computeRandomPerformance ( )
inlineprivate

Computes random performance.

boolean CommonKnowledge.containsKF ( KnowledgeField  kf)
inlineprivate

Tells whether the map 'knowledgeFields' contains a specific knowledge field. One cannot rely on the in-built method 'containsKey()' because it is based on knowledge fields hashcodes. We want to check whether a knowledge field is there, which has the same BEIs of another knowledge field. If it does, its ID must be changed because it must be the same knowledge field for us.

Parameters
kf
Returns
Return true if the map 'knowledgeFields' contains a specific, knowledge field, false otherwise.
KnowledgeField CommonKnowledge.getAlterEgo ( KnowledgeField  kf)
inlineprivate

Same procedure as 'containsKey' above, but the knowledge field is returned, which has the same BEIs as kf albeit (for the moment) a different ID.

Parameters
kf
Returns
Return the knowledge field
Map<KnowledgeField, CommonKnowledgeData> CommonKnowledge.getKnowledgeFields ( )
inline

Gets the whole tree of knowledge fields.

Returns
Return the whole tree.
int CommonKnowledge.getNumInstancesOfField ( KnowledgeField  kf)
inline

Gets the number of instances of a given field. Called by Model. If the field is not there, it returns zero.

Parameters
kf
Returns
Return the instances of a given field. If the field is not there, it returns zero.
double CommonKnowledge.getPerformance ( KnowledgeField  kf)
inline

CommonKnowledge may have stored a different knowledge field, entailing the same BEIs.

Parameters
kf
Returns
Returns the performance of a particular knowledge field.
int CommonKnowledge.setupGraphAndGetNumCN ( UndirectedSparseGraph  graph)
inlineprivate

Set up graph, adding nodes and edges. Return size of connected nodes.

Parameters
graphUndirectedSparseGraph
Returns
Return size of connected nodes.
void CommonKnowledge.updateField ( KnowledgeField  kf,
int  delta_n 
)
inline

It updates the number of instances of a knowledge field. It takes care that the calling knowledge field is eventually renamed as an instance of another knowledge field. This method works with delta_n <= 1, but it is called with delta_n = +-1. With delta_n = 1 the calling knowledge field is eventually renamed. (ONLY the calling knowledge field is renamed, that's why it doesn't work with delta_n > 1). In delta_n < 0 renaming is not necessary because the calling field(s) will be destroyed. If it is asked to update to a non-positive number of instances, it deletes the knowledge field.

Parameters
kf
delta_n
void CommonKnowledge.updatePerformance ( )
inline

Updates performance if the set of knowledge fields changed. Performance is computed according to the algorithm specified by originOfPerformance.

Member Data Documentation

HashMap<KnowledgeField, CommonKnowledgeData> CommonKnowledge.knowledgeFields
private
Initial value:
=
new HashMap<KnowledgeField, CommonKnowledgeData>()

Common knowledge is made of items composed by a knowledge field, the number of instances there are of it, and the performance it provides. It is organized as a hashmap with Key: KnowledgeField, and Value: CommonKnowledgeData, where CommonKnowledgeData is composed of the number of instances of this knowledge field and its performance.

boolean CommonKnowledge.mapsChanged
private

Whether the above map changed. It is set to 'true' by updateField and it is set to 'false' by updatePerformance.


The documentation for this class was generated from the following file: