Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package it.unimi.dsi.webgraph.labelling;
/*
* Copyright (C) 2007-2011 Paolo Boldi and Sebastiano Vigna
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see .
*
*/
import it.unimi.dsi.io.InputBitStream;
import it.unimi.dsi.io.OutputBitStream;
import it.unimi.dsi.lang.FlyweightPrototype;
import it.unimi.dsi.lang.ObjectParser;
import java.io.IOException;
import java.util.NoSuchElementException;
/** A set of attributes that can be used to decorate a node or
* an arc of a graph. Attributes appear in the form of <key,value>
* pairs, where keys are of type {@link String}. Among attributes,
* one (called the well-known attribute), has a special status:
* its key can be obtained by using the {@link #wellKnownAttributeKey()} method.
*
*
Values associated to attributes can be anything: the value can be
* obtained (in the form of an object) with {@link #get(String)}.
* If the value is of primitive type, the alternative type-specific method
* (e.g., {@link #getInt(String)}, or {@link #getChar(String)}) can be
* called, with the proviso that such methods may throw an {@link java.lang.IllegalArgumentException}
* if the attribute type can not be converted to the one specified without loss of information.
*
*
The value of the well-known attribute can be obtained with {@link #get()},
* or with the appropriate type-specific version of the method.
*
*
Serialisation
*
*
Implementations must provide {@link #toBitStream(OutputBitStream, int)} and {@link #fromBitStream(InputBitStream, int)}
* methods that serialise to a bitstream and deserialise to a bitstream a label, respectively. Since
* {@link #fromBitStream(InputBitStream, int)} has no length information, the label format must
* be self-delimiting. This can be obtained with a fixed length scheme (see, e.g., {@link FixedWidthIntLabel}),
* or using self-delimiting codes (see, e.g., {@link GammaCodedIntLabel}).
*
*
The methods {@link #toBitStream(OutputBitStream,int)}
* and {@link #fromBitStream(InputBitStream,int)} are given as an additional information the number of source
* node of the arc over which this label is put. They may use this information to decide how the
* label should be stored (typically, to do a more clever compression job).
*
*
The advantage of fixed-width labels (i.e., those for which {@link #fixedWidth()} does not return -1)
* is that when loading a {@link BitStreamArcLabelledImmutableGraph} with an offset step larger than 1 the position in the bitstream
* for the labels of a node can be calculated more quickly, as the computation just requires the outdegree
* of the nodes, whereas in general one has to skip in-between labels with an explicit deserialisation.
*
*
String-based constructors
*
*
By convention, all concrete classes implementing this interface must follow the {@link ObjectParser} conventions:
* in particular, they must provide a constructor accepting strings (either in fixed or variable number) where the first string is the key.
* The constructor must perform data validation and build an instance with a default value (e.g., 0 for numerical labels). The
* constructor is used, for instance, by {@link BitStreamArcLabelledImmutableGraph} to instantiate a label prototype.
* Finally, the method {@link #toSpec()} must return a string that is accepted by {@link ObjectParser}.
*/
public interface Label extends FlyweightPrototype