|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.links.WebGraph
public class WebGraph
This class implements a memory Data Structure for storing graphs.
A large amount of research has recently focused on the graph structure (or link structure) of the World Wide Web, which has proven to be extremely useful for improving the performance of search engines and other tools for navigating the web. For example, the Pagerank algorithm of Brin and Page, used in the Google search engine, and the HITS algorithm of Kleinberg both rank pages according to the number and importance of other pages that link to them.
This class provides the methods needed to efficiently compute with graphs and to experiment with such algorithms, using main memory for storage.
Field Summary | |
---|---|
private java.util.Map |
IdentifyerToURL
A Map storing relationships from numeric identifiers to URLs, usefull for storing Web graphs |
private java.util.Map |
InLinks
A Map storing InLinks. |
private int |
nodeCount
The number of nodes in the graph |
private java.util.Map |
OutLinks
A Map storing OutLinks. |
private java.util.Map |
URLToIdentifyer
A Map storing relationships from URLs to numeric identifiers, usefull for storing Web graphs |
Constructor Summary | |
---|---|
WebGraph()
Constructor for WebGraph |
|
WebGraph(java.io.File file)
Constructor for WebGraph, reading data from a text file. |
Method Summary | |
---|---|
private java.lang.Double |
addLink(java.lang.Integer fromLink,
java.lang.Integer toLink,
java.lang.Double weight)
Adds an association between two given nodes in the graph. |
void |
addLink(java.lang.String link)
Adds a node to the graph |
java.lang.Double |
addLink(java.lang.String fromLink,
java.lang.String toLink,
java.lang.Double weight)
Adds an association between two given nodes in the graph. |
java.lang.String |
IdentifyerToURL(java.lang.Integer id)
Returns the URL associated with a given identifyer |
java.lang.Double |
inLink(java.lang.Integer fromLink,
java.lang.Integer toLink)
Returns the connection strength between two nodes, assuming there is a connection from the first to the second. |
java.lang.Double |
inLink(java.lang.String fromLink,
java.lang.String toLink)
Returns the connection strength between two nodes, assuming there is a connection from the first to the second. |
java.util.Map |
inLinks(java.lang.Integer link)
Returns a Map of the nodes that connect to a given node in the graph. |
java.util.Map |
inLinks(java.lang.String URL)
Returns a Map of the nodes that connect to a given node in the graph. |
int |
numNodes()
Returns the number of nodes in the graph |
java.lang.Double |
outLink(java.lang.Integer fromLink,
java.lang.Integer toLink)
Returns the connection strength between two nodes, assuming there is a connection from the first to the second. |
java.lang.Double |
outLink(java.lang.String fromLink,
java.lang.String toLink)
Returns the connection strength between two nodes, assuming there is a connection from the first to the second. |
java.util.Map |
outLinks(java.lang.Integer link)
Returns a Map of the nodes that are connected from a given node in the graph. |
java.util.Map |
outLinks(java.lang.String URL)
Returns a Map of the nodes that are connected from a given node in the graph. |
void |
removeInternalLinks()
Remove nodes which correspond to an internal link. |
void |
removeNepotistic()
Remove nodes which correspond to nepotistic links. |
void |
removeStopLinks(java.util.Map stopURLs)
Remove nodes which correspond to stop URLs. |
void |
removeStopLinks(java.lang.String[] stopURLs)
Remove nodes which correspond to stop URLs. |
void |
transformUnidirectional()
Transforms a bi-directional graph to an uni-directional equivalent. |
java.lang.Integer |
URLToIdentifyer(java.lang.String URL)
Returns the identifyer associated with a given URL |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map IdentifyerToURL
private java.util.Map URLToIdentifyer
private java.util.Map InLinks
private java.util.Map OutLinks
private int nodeCount
Constructor Detail |
---|
public WebGraph()
public WebGraph(java.io.File file) throws java.io.IOException, java.io.FileNotFoundException
aux
- The name of the file
java.io.IOException
- An error occured while reading the file
java.io.FileNotFoundException
- An error occured while reading the fileMethod Detail |
---|
public java.lang.Integer URLToIdentifyer(java.lang.String URL)
URL
- The URL
public java.lang.String IdentifyerToURL(java.lang.Integer id)
id
- The identifyer
public void addLink(java.lang.String link)
link
- The URL associated with the added nodepublic java.lang.Double addLink(java.lang.String fromLink, java.lang.String toLink, java.lang.Double weight)
fromLink
- The URL for the source node in the graphfromLink
- The URL for the target node in the graphfromLink
- The strength to associate with the connection
private java.lang.Double addLink(java.lang.Integer fromLink, java.lang.Integer toLink, java.lang.Double weight)
fromLink
- The identifyer for the source node in the graphfromLink
- The identifyer for the target node in the graphfromLink
- The strength to associate with the connection
public java.util.Map inLinks(java.lang.String URL)
URL
- The URL for the node in the graph
public java.util.Map inLinks(java.lang.Integer link)
link
- The identifyer for the node in the graph
public java.util.Map outLinks(java.lang.String URL)
URL
- The URL for the node in the graph
public java.util.Map outLinks(java.lang.Integer link)
link
- The URL for the node in the graph
public java.lang.Double inLink(java.lang.String fromLink, java.lang.String toLink)
fromLink
- The source linktoLink
- The target link
inLink
public java.lang.Double outLink(java.lang.String fromLink, java.lang.String toLink)
fromLink
- The source linktoLink
- The target link
outLink
public java.lang.Double inLink(java.lang.Integer fromLink, java.lang.Integer toLink)
fromLink
- An identifyer for the source linktoLink
- An identifyer for the target link
outLink
public java.lang.Double outLink(java.lang.Integer fromLink, java.lang.Integer toLink)
fromLink
- An identifyer for the source linktoLink
- An identifyer for the target link
inLink
public void transformUnidirectional()
public void removeInternalLinks()
public void removeNepotistic()
public void removeStopLinks(java.lang.String[] stopURLs)
stopURLs
- An array of Strings with the Stop URLspublic void removeStopLinks(java.util.Map stopURLs)
stopURLs
- A Map where keys are the Stop URLspublic int numNodes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |