本文整理汇总了Java中sim.field.network.Edge类的典型用法代码示例。如果您正苦于以下问题:Java Edge类的具体用法?Java Edge怎么用?Java Edge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Edge类属于sim.field.network包,在下文中一共展示了Edge类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFriends
import sim.field.network.Edge; //导入依赖的package包/类
/** Return a set containing the current person's friends in the social graph.
*/
public Set<Person> getFriends() {
Bag myEdges = sim.socialNetwork.getEdges(this, null);
Set<Person> friends = new HashSet<Person>();
for (Object e1 : myEdges) {
Person from = (Person) ((Edge) e1).from();
Person to = (Person) ((Edge) e1).to();
if (from == this) {
friends.add(to);
} else {
friends.add(from);
}
}
return friends;
}
开发者ID:casific,项目名称:murmur,代码行数:19,代码来源:Person.java
示例2: getSharedFriends
import sim.field.network.Edge; //导入依赖的package包/类
/** Return a set containing the common friend with "other". This would be handled by a
* PSI operation in practice.
*
* @param other The person with whom we should compute mutual friends.
*/
public Set<Object> getSharedFriends(Person other) {
Bag myEdges = sim.socialNetwork.getEdges(this, null);
Bag otherEdges = sim.socialNetwork.getEdges(other, null);
Set<Object> sharedFriends = new HashSet<Object>();
for (Object e1 : myEdges) {
for (Object e2 : otherEdges) {
// There has to be some way to do this more elegantly?
Object myFrom = ((Edge) e1).from();
Object myTo = ((Edge) e1).to();
Object otherFrom = ((Edge) e2).from();
Object otherTo = ((Edge) e2).to();
Object myFriend = (myFrom == this) ? myTo : myFrom;
Object otherFriend = (otherFrom == other) ? otherTo : otherFrom;
// System.out.println(myFrom + " " + myTo + " " + otherFrom + " " + otherTo);
if (myFriend == otherFriend) {
sharedFriends.add(myFriend);
}
}
}
return sharedFriends;
}
开发者ID:casific,项目名称:murmur,代码行数:30,代码来源:Person.java
示例3: initializeNeighbourhood
import sim.field.network.Edge; //导入依赖的package包/类
@Test
public void initializeNeighbourhood() {
Bag edges = new Bag(3);
edges.add(new Edge(agent, agent1, 1));
edges.add(new Edge(agent, agent2, 1));
edges.add(new Edge(agent, agent3, 1));
Mockito.when(network.getEdgesIn(agent)).thenReturn(edges);
Mockito.reset(agent);
agent.initialize(true, network);
assertNotNull(agent.getNeighbourhood());
Mockito.verify(agent, Mockito.times(1)).calculateNeighbourhood(network);
assertEquals(3, agent.getNeighbourhood().size());
Mockito.reset(agent);
agent.initialize(true, network);
assertNotNull(agent.getNeighbourhood());
Mockito.verify(agent, Mockito.times(0)).calculateNeighbourhood(network);
assertEquals(3, agent.getNeighbourhood().size());
}
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:23,代码来源:AgentTest.java
示例4: draw
import sim.field.network.Edge; //导入依赖的package包/类
@Override
public void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
Edge e = (Edge) object;
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
final int midX = (int) (ei.draw.x + ei.secondPoint.x) / 2;
final int midY = (int) (ei.draw.y + ei.secondPoint.y) / 2;
graphics.setColor(Color.yellow);
graphics.drawLine(startX, startY, endX, endY);
Link link = (Link) e.getInfo();
graphics.setColor(Color.blue);
graphics.setFont(labelFont);
int width = graphics.getFontMetrics().stringWidth(link.getID());
graphics.drawString( link.getID(), midX - width / 2, midY );
}
开发者ID:gsi-upm,项目名称:Shanks,代码行数:23,代码来源:Link2DPortrayal.java
示例5: getSellers
import sim.field.network.Edge; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Bag getSellers(final Party buyer) {
final Bag edges = network.getEdgesIn(buyer);
final Bag sellers = new Bag();
for (final Iterator<Edge> iterEdges = edges.iterator(); iterEdges.hasNext();) {
sellers.add(iterEdges.next().from());
}
return sellers;
}
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:10,代码来源:ConstraintMarket.java
示例6: getBuyers
import sim.field.network.Edge; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Bag getBuyers(final Party seller) {
final Bag edges = network.getEdgesOut(seller);
final Bag buyers = new Bag();
for (final Iterator<Edge> iterEdges = edges.iterator(); iterEdges.hasNext();) {
buyers.add(iterEdges.next().to());
}
return buyers;
}
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:10,代码来源:ConstraintMarket.java
示例7: draw
import sim.field.network.Edge; //导入依赖的package包/类
public void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
Edge e = (Edge) object;
Link link = (Link) e.getInfo();
Color color = null;
if (link.getClass().equals(SensorLink.class)) {
color = Color.green;
} else if (link.getClass().equals(RoutePathLink.class)) {
color = Color.black;
}
this.drawSimpleLink(link, object, graphics, info, color);
}
开发者ID:gsi-upm,项目名称:shanks-wsn-module,代码行数:15,代码来源:WirelessLink2DPortrayal.java
示例8: calculateNeighbourhood
import sim.field.network.Edge; //导入依赖的package包/类
/**
* Calculate the neighbourhood of this agent by the given network.
*
* @return agent
*/
protected Bag calculateNeighbourhood(Network network) {
Bag edges = new Bag(network.getEdgesIn(this));
Bag neighbours = new Bag();
for (int i = 0, si = edges.size(); i < si; i++) {
Edge edge = (Edge) edges.get(i);
Agent neighbour = (Agent) edge.getOtherNode(this);
neighbours.add(neighbour);
}
return neighbours;
}
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:17,代码来源:Agent.java
示例9: drawLink
import sim.field.network.Edge; //导入依赖的package包/类
/**
* To draw a link
*
* @param link
*/
public void drawLink(Link link) {
List<Device> linkedDevices = link.getLinkedDevices();
for (int i = 0; i<linkedDevices.size(); i++) {
Device from = linkedDevices.get(i);
for (int j = i+1 ; j<linkedDevices.size(); j++) {
Device to = linkedDevices.get(j);
Edge e = new Edge(from, to, link);
links.addEdge(e);
}
}
}
开发者ID:gsi-upm,项目名称:Shanks,代码行数:17,代码来源:Scenario3DPortrayal.java
示例10: drawLink
import sim.field.network.Edge; //导入依赖的package包/类
/**
* To draw a link
*
* @param link
*/
public void drawLink(Link link) {
List<Device> linkedDevices = link.getLinkedDevices();
for (int i = 0; i < linkedDevices.size(); i++) {
Device from = linkedDevices.get(i);
for (int j = i + 1; j < linkedDevices.size(); j++) {
Device to = linkedDevices.get(j);
Edge e = new Edge(from, to, link);
links.addEdge(e);
}
}
}
开发者ID:gsi-upm,项目名称:Shanks,代码行数:17,代码来源:Scenario2DPortrayal.java
示例11: draw
import sim.field.network.Edge; //导入依赖的package包/类
public void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
Edge e = (Edge) object;
Link link = (Link) e.getInfo();
if (link.getCapacity() == 2) {
this.drawSimpleLink(link, object, graphics, info);
} else if (link.getCapacity() > 2) {
this.drawComplexLink(link, object, graphics, info);
}
}
开发者ID:gsi-upm,项目名称:Shanks,代码行数:12,代码来源:MyLink2DPortrayal.java
示例12: getLabel
import sim.field.network.Edge; //导入依赖的package包/类
public String getLabel(Edge e) {
return "";
}
开发者ID:gsi-upm,项目名称:TwitterSimulator,代码行数:4,代码来源:LinkPortrayal3D.java
注:本文中的sim.field.network.Edge类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论