本文整理汇总了Java中org.jgraph.graph.DefaultEdge类的典型用法代码示例。如果您正苦于以下问题:Java DefaultEdge类的具体用法?Java DefaultEdge怎么用?Java DefaultEdge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultEdge类属于org.jgraph.graph包,在下文中一共展示了DefaultEdge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testJGraph
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
@Test
public void testJGraph() throws Exception {
GraphModel model = new DefaultGraphModel();
GraphLayoutCache view = new GraphLayoutCache(model, new DefaultCellViewFactory());
JGraph graph = new JGraph(model, view);
DefaultGraphCell[] cells = new DefaultGraphCell[3];
cells[0] = createCell("hello", true);
cells[1] = createCell("world", false);
DefaultEdge edge = new DefaultEdge();
GraphConstants.setLineStyle(edge.getAttributes(), GraphConstants.ARROW_LINE);
edge.setSource(cells[0].getChildAt(0));
edge.setTarget(cells[1].getChildAt(0));
cells[2] = edge;
graph.getGraphLayoutCache().insert(cells);
JOptionPane.showMessageDialog(null, new JScrollPane(graph));
}
示例2: createDistinguishabilityGraph
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public UndirectedGraph<FsmState, DefaultEdge> createDistinguishabilityGraph(FsmTestTree testTree) {
UndirectedGraph<FsmState, DefaultEdge> dg = new SimpleGraph<FsmState, DefaultEdge>(DefaultEdge.class);
for (FsmState node : testTree.getStates()) {
dg.addVertex(node);
}
FsmState statei = null;
FsmState statej = null;
for (int i = 0; i < testTree.getStates().size()-1; i++) {
for (int j = i+1; j < testTree.getStates().size(); j++) {
statei = testTree.getStates().get(i);
statej = testTree.getStates().get(j);
if(isT_Distinguishable(statei,statej)){
dg.addEdge(statei,statej);
}
}
}
return dg;
}
示例3: canApplyLemma2
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
/**
* @param alpha This is the FsmState of a FsmTestTree which represents a test sequence.
* @param labels This collections maps states to its labels.
* @param k_set This is the set of cliques obtained from a distinguishability graph and which alpha must match n-1 elements to be linked
* @param dg This is the graph where alpha will be connected to one of the elements from k_set if it can be distinguished from n-1 elements
* @return TRUE if alpha can be distinguished from n-1 states from k_set
*/
public boolean canApplyLemma2(FsmState alpha, Map<Integer, Set<FsmState>> labels, Set<FsmState> k_set, UndirectedGraph<FsmState, DefaultEdge> dg) {
/* when distinguishable add alpha in the labels */
List<Integer> notConnected = new ArrayList<Integer>();
notConnected.addAll(labels.keySet());
for (Integer key : labels.keySet()){
for(FsmState s: labels.get(key))
if(dg.containsEdge(alpha,s)){
notConnected.remove(key);
break;
}
}
if(notConnected.size()==1){
labels.get(notConnected.get(0)).add(alpha);
return true;
}
return false;
}
示例4: addEdge
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public void addEdge( int source, int target){
//System.out.println("adding edge: "+source+"->"+ target+ "to cell "+cellCount);
DefaultEdge edge = new DefaultEdge();
edge.setSource(cells[source].getChildAt(0));
edge.setTarget(cells[target].getChildAt(0));
int arrow = GraphConstants.ARROW_CLASSIC;
GraphConstants.setLineEnd(edge.getAttributes(), arrow);
GraphConstants.setEndFill(edge.getAttributes(), true);
// Node s = (Node)cells[source].getUserObject();
// Node t = (Node)cells[target].getUserObject();
/* _edge.arrow_x=(int)(s.x+t.x)/2;
_edge.arrow_y=(int)(s.y+t.y)/2;*/
cells[cellCount] = edge;
edgeCount++;
cellCount++;
}
示例5: getJobDags
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
private void getJobDags(Path benchmarkfolder) throws IOException,
ClassNotFoundException {
// Assuming dag of all jobs are the same, we have to do it
// only for the first folder
if (jobDags.size() == 0) {
Path dagDirectory = Paths.get(benchmarkfolder.toAbsolutePath()
.toString(), "dags");
DirectoryStream<Path> dagStream = Files
.newDirectoryStream(dagDirectory);
for (Path file : dagStream) {
if (file.toFile().isFile()) {
logger.debug("loading " + file.getFileName() + " dag");
DirectedAcyclicGraph<Stagenode, DefaultEdge> dag = Utils
.deserializeFile(file);
if (dag != null) {
int jobId = dag.vertexSet().iterator().next()
.getJobId();
jobDags.put(jobId, dag);
}
}
}
dagStream.close();
}
}
示例6: deserializeFile
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
/**
* Deserializes the file containign a Stage DAG
*
* @param file
* @return
* @throws IOException
* @throws ClassNotFoundException
*/
static DirectedAcyclicGraph<Stagenode, DefaultEdge> deserializeFile(
Path file) throws IOException, ClassNotFoundException {
InputStream fileIn = Files.newInputStream(file);
DirectedAcyclicGraph<Stagenode, DefaultEdge> dag = null;
ObjectInputStream in = null;
try {
in = new ObjectInputStream(fileIn);
dag = (DirectedAcyclicGraph<Stagenode, DefaultEdge>) in
.readObject();
} catch (StreamCorruptedException e) {
logger.warn("file "
+ file.getFileName()
+ " is not a valid DAG or has been serialized badly. Skipping it");
} finally {
if (in != null)
in.close();
fileIn.close();
}
return dag;
}
示例7: unhandled_node
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
@Override
protected Object unhandled_node(SimpleNode node) throws Exception {
DefaultGraphCell cell = null;
String caption = node.toString();
parentAddPort();
cell = createVertex(caption, indent, depth, nodeColor, false);
DefaultEdge edge = createConnection(cell);
cells.add(cell);
cells.add(edge);
incrementPosition(cell);
return null;
}
示例8: removeLink
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public void removeLink(DataBean source, DataBean target, Link type) {
GraphVertex sourceVertex = vertexMap.get(source);
GraphVertex targetVertex = vertexMap.get(target);
if (type.equals(Link.GROUPING)) {
sourceVertex.getGroup().removeChildVertex(sourceVertex);
} else {
for (DefaultEdge edge : getAllEdgesOfVertex(sourceVertex, this)) {
// Get link type, source vertex and target vertex
Link edgeType = (Link) edge.getUserObject();
GraphVertex edgeSource = (GraphVertex) ((DefaultPort) edge.getSource()).getParent();
GraphVertex edgeTarget = (GraphVertex) ((DefaultPort) edge.getTarget()).getParent();
logger.debug("Edge type: " + edgeType + ", edgeSource: " + edgeSource + ", edgeTarget: " + edgeTarget);
if (edgeSource.equals(sourceVertex) && edgeTarget.equals(targetVertex) && edgeType.equals(type)) {
// Remove the edge if target, source and link type matched
graphLayoutCache.remove(new Object[] { edge });
}
}
}
}
示例9: MappingViewCommonComponent
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public MappingViewCommonComponent(MappableNode sourceNode, MappableNode targetNode,
DefaultGraphCell sourceCell, DefaultGraphCell targetCell, DefaultEdge linkEdge)
{
if(sourceNode==null)
{
throw new IllegalArgumentException("Source Node cannot be null!");
}
if(targetNode==null)
{
throw new IllegalArgumentException("Target Node cannot be null!");
}
// MappableNode localSourceNode = null;
// MappableNode localTargetNode = null;
determineSourceAndTargetNode(sourceNode, sourceCell);
determineSourceAndTargetNode(targetNode, targetCell);
this.linkEdge = linkEdge;
// this.sourceNode = sourceNode;
// this.targetNode = targetNode;
// this.sourceCell = sourceCell;
// this.targetCell = targetCell;
}
示例10: unmapCells
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
private void unmapCells(Object[] cells) {
// System.out.println("middlePanel kind: " + middlePanel.getKind() );
for (int i = 0; i < cells.length; i++) {
if (cells[i] == null || !(cells[i] instanceof DefaultEdge))
continue;
DefaultEdge linkEdge = (DefaultEdge) cells[i];
DefaultPort srcPort = (DefaultPort) linkEdge.getSource();
if (srcPort instanceof FunctionBoxGraphPort)
((FunctionBoxGraphPort) srcPort).setMapStatus(false);
else {
MappableNode sourceNode = (MappableNode) srcPort
.getUserObject();
sourceNode.setMapStatus(false);
}
DefaultPort trgtPort = (DefaultPort) linkEdge.getTarget();
if (trgtPort instanceof FunctionBoxGraphPort)
((FunctionBoxGraphPort) trgtPort).setMapStatus(false);
else {
MappableNode targetNode = (MappableNode) trgtPort
.getUserObject();
targetNode.setMapStatus(false);
}
}
}
示例11: MappingViewCommonComponent
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public MappingViewCommonComponent(MappableNode sourceNode, MappableNode targetNode,
DefaultGraphCell sourceCell, DefaultGraphCell targetCell, DefaultEdge linkEdge)
{
if(sourceNode==null)
{
throw new IllegalArgumentException("Source Node cannot be null!");
}
if(targetNode==null)
{
throw new IllegalArgumentException("Target Node cannot be null!");
}
// determineSourceAndTargetNode(sourceNode, sourceCell);
// determineSourceAndTargetNode(targetNode, targetCell);
this.linkEdge = linkEdge;
this.sourceNode = sourceNode;
this.targetNode = targetNode;
this.sourceCell = sourceCell;
this.targetCell = targetCell;
}
示例12: build
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public static BasicDominatorInfo build(Iterable<Basic> basics)
{
DirectedGraph<Name, DefaultEdge> graph;
graph = new DefaultDirectedGraph<>(DefaultEdge.class);
basics.forEach(basic -> graph.addVertex(basic.getName()));
basics.forEach(s ->
s.getAllTargets().forEach(d -> {
if (!Basics.TERMINAL_NAMES.contains(d)) {
graph.addEdge(s.getName(), d);
}
}));
DominatorTree<Name, DefaultEdge> impl = new DominatorTree<>(graph, Basics.ENTRY_NAME);
Map<Name, Set<Name>> dominatedTree = invertTree(impl.getDominatorTree()::get, Basics.ENTRY_NAME);
return new BasicDominatorInfo(impl, dominatedTree);
}
示例13: canApplyLemma3
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
/**
* @param alpha This is the FsmState of a FsmTestTree which represents a test sequence.
* @param labels This collections maps states to its labels.
* @param dg This is the graph where two beta and chi sequences converging to a same state will be searched.
* Alpha is prefix of chi extended with gamma. All beta,beta+gamma,chi, and chi+gamma (alpha) all belong to dg
* @return returns true if beta,beta+gamma,chi, and chi+gamma (alpha) all exist return TRUE
*/
public boolean canApplyLemma3(FsmState alphaState, Map<Integer, Set<FsmState>> labels, Set<FsmState> k_set, UndirectedGraph<FsmState, DefaultEdge> dg) {
//TODO search until the root of the tree
// get phi sequence
List<FsmTransition> phi = getPhi(alphaState,k_set);
if(phi.size()>0){
FsmState chiState = phi.get(0).getFrom();
Integer chiLabel = null;
Set<FsmState> labeledAsChi = new HashSet<FsmState>();
for (Integer l : labels.keySet()) {
if(labels.get(l).contains(chiState)){
chiLabel = l;
labeledAsChi.addAll(labels.get(l));
break;
}
}
for (FsmState beta : labeledAsChi) {
FsmState betaPhi = applySequence(beta,phi);
if(betaPhi != null){
Integer betaPhiLabel = getLabel(betaPhi,labels);
if(betaPhiLabel != null){
labels.get(betaPhiLabel).add(alphaState);
return true;
}
}
}
}
return false;
}
示例14: saveDistinguishingGraphAsDotFile
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
public void saveDistinguishingGraphAsDotFile(UndirectedGraph<FsmState, DefaultEdge> dg, File f){
try {
DistinguishGraphUtils dgutils = DistinguishGraphUtils.getInstance();
dgutils.saveDistinguishabilityGraph(dg,f);
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: serializeDag
import org.jgraph.graph.DefaultEdge; //导入依赖的package包/类
/**
* serializes the DAG for later use
*
* @param dag
* @param string
* - the name of the file in which serialize the DAG
* @throws IOException
*/
private static void serializeDag(DirectedAcyclicGraph<?, DefaultEdge> dag,
String filename) throws IOException {
// to debug locally on windows
OutputStream os = hdfs.create(new Path(new Path(config.outputFolder,
"dags"), filename));
ObjectOutputStream objectStream = new ObjectOutputStream(os);
objectStream.writeObject(dag);
objectStream.close();
os.close();
}